Phalcon TutorialPHP Tutorials Phalcon Insert/Update/Delete Rows by Online Tutorials Library July 14, 2022 117 Insert/Update/Delete Rows Inserting Rows // Inserting data with a raw SQL statement $sql = ‘INSERT INTO ‘company'(‘name’, ‘year’) VALUES (‘tutoraspire’, 2010)’; $success = $connection->execute($sql); // With placeholders $sql = ‘INSERT INTO ‘company'(‘name’, ‘year’) VALUES (?, ?)’; $success = $connection->execute( $sql, [ ‘tutoraspire’, 2010, ] ); // Generating dynamically the necessary SQL $success = $connection->insert( ‘company’, [ ‘tutoraspire’, 2010, ], [ ‘name’, ‘year’, ], ); Output: Updating Rows // Updating data with a raw SQL statement $sql = ‘UPDATE ‘company’ SET ‘name’ = ‘tutoraspire’ WHERE ‘id’ = 101′; $success = $connection->execute($sql); // With placeholders $sql = ‘UPDATE ‘company’ SET ‘name’ = ? WHERE ‘id’ = ?’; $success = $connection->execute( $sql, [ ‘tutoraspire’, 101, ] ); // Generating dynamically the necessary SQL (another syntax) $success = $connection->updateAsDict( ‘company’, [ ‘name’ =>’New tutoraspire’, ], ‘id = 101’ // Warning! In this case values are not escaped ); Output: Deleting Rows // Deleting data with a raw SQL statement $sql = ‘DELETE ‘company’ WHERE ‘id’ = 101′; $success = $connection->execute($sql); // With placeholders $sql = ‘DELETE ‘company’ WHERE ‘id’ = ?’; $success = $connection->execute($sql, [101]); // Generating dynamically the necessary SQL $success = $connection->delete( ‘company’, ‘id = ?’, [ 101, ] ); Next TopicPhalcon Transaction and Nested Transaction cacheclass autoloaderconfrigurationcookiesdatabasefeaturesfirst exampleformsimagesintroductionlayerloggingmodelsphalcon tutorialphqlrequestresponseviewvolt Share 0 FacebookTwitterPinterestEmail previous post Insert PDF into Word File next post Blending Modes in Photoshop You may also like PHP strtr() Function PHP substr() Function PHP chunk_split() function PHP strcasecmp() function PHP crypt() function PHP addcslashes() function