Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted March 26, 20159 yr could someone provide me with some examples of the new data base queries for build, execute, update etc, or provide me with a link where I can find them
March 28, 20159 yr Take a look at the \IPS\Db Class The most important methods are /** * Run INSERT statement and return insert ID * * @see <a href='http://dev.mysql.com/doc/refman/5.0/en/insert.html'>INSERT Syntax</a> * @param string $table Table name * @param array|\IPS\Db\Select $set Values to insert or array of values to set for multiple rows (NB, if providing multiple rows, they MUST all contain the same columns) or a statement to do INSERT INTO SELECT FROM * @param bool $odkUpdate Append an ON DUPLICATE KEY UPDATE clause to the query. Similar to the replace() method but updates if a record is found, instead of delete and reinsert. * @see \IPS\Db::replace() * @return int * @throws \IPS\Db\Exception */ public function insert( $table, $set, $odkUpdate=FALSE ) /** * Build SELECT statement * * @param array|string $columns The columns (as an array) to select or an expression * @param array|string $table The table to select from. Either (string) table_name or (array) ( name, alias ) or \IPS\Db\Select object * @param array|string|NULL $where WHERE clause (see example) * @param string|NULL $order ORDER BY clause * @param array|int $limit Rows to fetch or array( offset, limit ) * @param string|NULL|array $group Column(s) to GROUP BY * @param array|string|NULL $having HAVING clause (same format as WHERE clause) * @param int $flags Bitwise flags * @li \IPS\Db::SELECT_DISTINCT Will use SELECT DISTINCT * @li \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS Will add SQL_CALC_FOUND_ROWS * @li \IPS\Db::SELECT_MULTIDIMENSIONAL_JOINS Will return the result as a multidimensional array, with each joined table separately * @return \IPS\Db\Select * */ public function select( $columns=NULL, $table, $where=NULL, $order=NULL, $limit=NULL, $group=NULL, $having=NULL, $flags=0 ) /** * Run UPDATE statement and return number of affected rows * * @see \IPS\Db::build * @see <a href='http://dev.mysql.com/doc/refman/5.0/en/update.html'>UPDATE Syntax</a> * @param string|array $table Table Name, or array( Table Name => Identifier ) * @param string|array $set Values to set (keys should be the table columns) or pre-formatted SET clause or \IPS\Db\Select object * @param mixed $where WHERE clause (see \IPS\Db::build for details) * @param array $joins Tables to join (see \IPS\Db::build for details) * @param int|array|null $limit LIMIT clause (see \IPS\Db::build for details) * @param int $flags Bitwise flags * @li \IPS\Db::LOW_PRIORITY Will use LOW_PRIORITY * @li \IPS\Db::IGNORE Will use IGNORE * @return int * @throws \IPS\Db\Exception */ public function update( $table, $set, $where='', $joins=array(), $limit=NULL, $flags=0 ) /** * Run DELETE statement and return number of affected rows * * @see \IPS\Db::build * @see <a href='http://dev.mysql.com/doc/refman/5.0/en/delete.html'>DELETE Syntax</a> * @param string $table Table Name * @param string|array|\IPS\Db\Statement|null $where WHERE clause (see \IPS\Db::build for details) * @param string|null $order ORDER BY clause (see \IPS\Db::build for details) * @param int|array|null $limit LIMIT clause (see \IPS\Db::build for details) * @param string|null $statementColumn If \IPS\Db\Statement is passed, this is the name of the column that results are being loaded from * @return \IPS\Db\Statement * @throws \IPS\Db\Exception */ public function delete( $table, $where=NULL, $order=NULL, $limit=NULL, $statementColumn=NULL )
Archived
This topic is now archived and is closed to further replies.