/**
* Executes a prepared statement that returns data
- * Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
+ * Example: $r = p("SELECT * FROM `post` WHERE `guid` = ?", $guid);
*
* Please only use it with complicated queries.
* For all regular queries please use DBA::select or DBA::exists
/**
* Insert a row into a table
*
- * @param string|array $table Table name or array [schema => table]
- * @param array $param parameter array
- * @param bool $on_duplicate_update Do an update on a duplicate entry
+ * @param string|array $table Table name or array [schema => table]
+ * @param array $param parameter array
+ * @param int $duplicate_mode What to do on a duplicated entry
*
* @return boolean was the insert successful?
* @throws \Exception
*/
- public static function insert($table, $param, $on_duplicate_update = false)
+ public static function insert($table, array $param, int $duplicate_mode = Database::INSERT_DEFAULT)
{
- return DI::dba()->insert($table, $param, $on_duplicate_update);
+ return DI::dba()->insert($table, $param, $duplicate_mode);
}
/**
* @return boolean|object
*
* Example:
- * $table = "item";
+ * $table = "post";
* $fields = array("id", "uri", "uid", "network");
*
* $condition = array("uid" => 1, "network" => 'dspr');
* @return int
*
* Example:
- * $table = "item";
+ * $table = "post";
*
* $condition = ["uid" => 1, "network" => 'dspr'];
* or:
return DI::dba()->toArray($stmt, $do_close);
}
+ /**
+ * Cast field types according to the table definition
+ *
+ * @param string $table
+ * @param array $fields
+ * @return array casted fields
+ */
+ public static function castFields(string $table, array $fields)
+ {
+ return DI::dba()->castFields($table, $fields);
+ }
+
/**
* Returns the error number of the last query
*