C3rd
PHP: about NULL vs 0
Posted: 18 Sep 2017, 20:43pm - MondayA client reported about the data wasn't populating... So I debug and took me hours to find out... Background: We have this enterprise system with legacy code and we created a QueryDriver class to make the legacy, Silex DBAL & CodeIgniter works and reusable. Behind the QueryDriver, it uses vsprintf() function.
$parcelData = []; $jobVarObj = new JobsVarsTable(); $jobVarObj->setDrivers($this->getQueryDriver()); $prime_parcel = $jobVarObj->getVarValue($this->job_id, 'PRIMARY_PARCEL'); ... $q = "SELECT * FROM jobs_parcels WHERE JID = '%d' AND ID != '%d' AND Deleted IS NULL"; $sql = $this->getQueryDriver()->fetchAll($q, [$this->job_id, $prime_parcel]); $parcel_data_list = $sql->getData();In that codes above, the $parcel_data_list is always empty and I know there are 1 row results.

$parcelData = []; $jobVarObj = new JobsVarsTable(); $jobVarObj->setDrivers($this->getQueryDriver()); $prime_parcel = (int)$jobVarObj->getVarValue($this->job_id, 'PRIMARY_PARCEL', 'n'); ... $q = "SELECT * FROM jobs_parcels WHERE JID = '%d' AND ID != '%d' AND Deleted IS NULL"; $sql = $this->getQueryDriver()->fetchAll($q, [$this->job_id, $prime_parcel]); $parcel_data_list = $sql->getData();Then it solves my 2hrs problem!!! Ok that's my entry for half of 2017... hehehe.. Cheers!
Search
Categories
Related Links
- Apache Web Server
- ASP Immigration Services Ltd.
- CentOS Linux
- Color Scheme Picker
- CSS Button Generator
- Deviant Art Account
- Don Tabaniag - GraphiCult
- Jerson Maglasang Weblog
- Joshua Manlunas
- Mark "mungkey" Vicente
- Matt Arnilo Baluyos
- MySQL
- Paul Labis
- PHP
- PrendStar
- Ridvan Baluyos
- Scott Davies
- SEO Fart XML-RPC Ping Tool
- Stripes Generator
- The Hero
- Ubuntu Linux
- Vim Carlo Nabora (DA)
- Wella Maria Hong
- What is my IP?
- Xavier University - Ateneo de Cagayan
- Zabyer Community