/// <inheritDoc /> public override string GetLastInsertId(PDO pdo, string name) { var command = pdo.GetCurrentCommand(); var lastid = command != null?MySqlExtensions.LastInsertedId(command) : -1; return(lastid.ToString()); }
/// <inheritDoc /> public override string GetLastInsertId(PDO pdo, string name) { pdo.ClosePendingReader(); string last_insert_id_query; if (string.IsNullOrEmpty(name)) { last_insert_id_query = "SELECT @@IDENTITY"; } else { // TODO: "SELECT CURRENT_VALUE FROM SYS.SEQUENCES WHERE NAME=%s" throw new NotImplementedException(nameof(name)); } using (var com = pdo.CreateCommand(last_insert_id_query)) { var value = com.ExecuteScalar(); if (value == null) { // TODO: error return(null); } return(value.ToString()); } }
/// <inheritDoc /> public override string GetLastInsertId(PDO pdo, string name) { var command = (MySqlCommand)pdo.GetCurrentCommand(); var lastid = (command != null) ? command.LastInsertedId : -1; return(lastid.ToString()); }
/// <inheritDoc /> public override string GetLastInsertId(PDO pdo, string name) { using (var com = pdo.CreateCommand("SELECT SCOPE_IDENTITY()")) { object value = com.ExecuteScalar(); return(value?.ToString()); } }
private static PhpValue sqliteCreateCollation(PDO pdo, PhpArray arguments) { #if NET46 throw new NotImplementedException(); #else return(PhpValue.False); #endif }
/// <inheritDoc /> public override string GetLastInsertId(PDO pdo, string name) { using (var cmd = pdo.CreateCommand("SELECT LAST_INSERT_ID()")) { object value = cmd.ExecuteScalar(); return(value?.ToString()); } }
/// <inheritDoc /> public override string GetLastInsertId(PDO pdo, string name) { //TODO firebird pdo characters escaping using (var cmd = pdo.CreateCommand("select gen_id('" + name + "', 0) from rdb$database")) { object value = cmd.ExecuteScalar(); return(value?.ToString()); } }
/// <inheritDoc /> public override string GetLastInsertId(PDO pdo, string name) { // The last_insert_rowid() SQL function is a wrapper around the sqlite3_last_insert_rowid() // https://www.sqlite.org/lang_corefunc.html#last_insert_rowid using (var cmd = pdo.CreateCommand("SELECT LAST_INSERT_ROWID()")) { object value = cmd.ExecuteScalar(); // can't be null return(value != null?value.ToString() : string.Empty); } }
private static PhpValue sqliteCreateFunction(PDO pdo, PhpArray arguments) { #if NET46 throw new NotImplementedException(); // From https://github.com/DEVSENSE/Phalanger/blob/master/Source/Extensions/PDOSQLite/SQLitePDODriver.cs // SQLiteFunction.RegisterFunction(func_name, nbr_arg, FunctionType.Scalar, null, d, null); #else //Microsoft connector does not support CreateFunction return(PhpValue.False); #endif }
public static Builders make(Db db) { Builders builder = null; string type = PDO.getPdoType(); if (type == "sqlserver") { builder = new SqlServer(db); } return(builder); }
/// <inheritDoc /> public override string GetLastInsertId(PDO pdo, string name) { Debug.Fail("last_insert_id not implemented"); // this is probably not correct: using (var cmd = pdo.CreateCommand("SELECT LAST_INSERT_ROWID()")) { object value = cmd.ExecuteScalar(); return(value?.ToString()); } }
public ActionResult CheckPharmacist(PDO pdo)//PDO { if (pdo != null) { DBQueries queryObj = new DBQueries(); string sqlQuery = string.Format(queryObj.sqlCheckPDOPharmacist, pdo.PHARMACY_ID, pdo.FIRST_NAME, pdo.LAST_NAME); string result = dbCommon.GetValue(sqlQuery, "PDO"); if (Convert.ToInt16(result) < 1) { return(Json("1", JsonRequestBehavior.AllowGet)); } } return(Json("0", JsonRequestBehavior.AllowGet)); }
public ActionResult AddPharmacist(PDO pdo)//PDO { int result; if (pdo != null) { DBQueries queryObj = new DBQueries(); string sqlQuery = string.Format(queryObj.AddPDOPharmacist, pdo.PHARMACY_ID, pdo.FIRST_NAME, pdo.LAST_NAME, getUserId()); result = dbCommon.ExcecuteNonQuery(sqlQuery, "PDO"); if (result == 1) { return(Json("Y", JsonRequestBehavior.AllowGet)); } } return(Json("", JsonRequestBehavior.AllowGet)); }
/// <inheritDoc /> public override bool TrySetAttribute(PDO pdo, Dictionary <PDO.PDO_ATTR, PhpValue> attributes, int attribute, PhpValue value) { return(false); }
private static PhpValue sqliteCreateFunction(PDO pdo, PhpArray arguments) { //Microsoft connector does not support CreateFunction return(PhpValue.False); }
private static PhpValue sqliteCreateCollation(PDO pdo, PhpArray arguments) { return(PhpValue.False); }
/// <inheritDoc /> public override string GetLastInsertId(PDO pdo, string name) { throw new NotImplementedException(); }
/// <summary> /// Gets underlaying <see cref="DbConnection"/> of a <see cref="PDO"/> object. /// </summary> /// <typeparam name="TConnection"></typeparam> /// <param name="pdo">PDO object instance.</param> /// <returns>Underlaying connection. Can be <c>null</c>.</returns> public static TConnection GetCurrentConnection <TConnection>(this PDO pdo) where TConnection : DbConnection => pdo.Connection as TConnection;
/// <summary> /// Closes pending data reader if any. /// </summary> public static void ClosePendingReader(this PDO pdo) => pdo.ClosePendingReader();
/// <summary> /// Creates command using provided PDO driver. /// </summary> public static DbCommand CreateCommand(this PDO pdo, string statement) => pdo.CreateCommand(statement);
virtual protected Hashtable parseData(Hashtable data, bool isInsert) { Hashtable result = new Hashtable(); // 分析数据 try { var sql = getTableFind(parseTable()); PDO pdo = new PDO(); ResultSet resultSet = pdo.query(sql); int length = resultSet.columnCount(); for (int i = 0; i < length; i++) { string col = resultSet.columnName(i); string type = resultSet.columnType(i); if (col.ToLower().Equals("id")) { continue; } if (data.ContainsKey(col)) { object content = data[col]; if (content is ArrayList) { ArrayList var = (ArrayList)content; if (var[0].Equals("inc") || var[0].Equals("dec")) { string fuhao = var[0].Equals("inc") ? "+" : "-"; result.Add(col, col + fuhao + var[1]); } } else { result.Add(col, getFieldValue(type, content.ToString())); } } else { if (isInsert) { result.Add(col, getFieldDefault(type)); } } } resultSet.Dispose(); pdo.Dispose(); /* * DataSet dataSet = Connect.getDataSet(sql); * DataColumnCollection columns = dataSet.Tables[0].Columns; * for (int i = 0; i < columns.Count; i++) * { * DataColumn column = columns[i]; * string col = column.ColumnName; * string type = column.DataType.ToString(); * if (col.ToLower().Equals("id")) * { * continue; * } * if (data.ContainsKey(col)) * { * object content = data[col]; * if (content is ArrayList) * { * ArrayList var = (ArrayList) content; * if (var[0].Equals("inc") || var[0].Equals("dec")) * { * string fuhao = var[0].Equals("inc") ? "+" : "-"; * result.Add(col, col + fuhao + var[1]); * } * } * else * { * result.Add(col, getFieldValue(type, content.ToString())); * } * } * else * { * if (isInsert) * { * result.Add(col, getFieldDefault(type)); * } * } * }*/ } catch (Exception e) { Console.WriteLine(e); } return(result); }
/// <summary> /// Gets last created command. /// </summary> public static DbCommand GetCurrentCommand(this PDO pdo) => pdo.CurrentCommand;
/// <inheritDoc /> public override bool TrySetStringifyFetches(PDO pdo, bool stringify) { // SQLite PDO driver can retrieve values only as strings in PHP pdo.Stringify = true; return(stringify == true); }