php - Laravel Raw DB Insert Affected Rows -


i'm using raw queries laravel 4, is there way check affected rows on insert? db::getpdo()->rowcount(); gives me "undefined method" error. code follows:

$query = "insert ignore table (id) values (?)"; $doquery = db::insert($query, array($value)); if ($doquery) {     return db::getpdo()->last(); } else {     return 0; } 

if not, there easy way figure out whether insert done or not without making 2 queries?

well figured out workaround should efficient - use insert instead of insert ignore , use try/catch.

   $query = "insert table (id) values (?)";     try {         db::insert($query, array($value));         return 1;     } catch (\exception $e) {         return 0;     } 

Comments

Popular posts from this blog

android - questions about switching from C2DM to GCM -

c++ - Qt setGeometry: Unable to set geometry -

batch file - How to extract all multi-volume RAR archives from subfolders of a folder? -