User avatar
micksulley
Posts: 138
Joined: Sat Mar 03, 2012 11:48 am
Location: Melton Mowbray, England

MariaDB PDO Driver - No Value

Sat Dec 30, 2017 4:41 pm

I have been using MySQL on Pi's for a while, but on a new install I have MariaDB and I am having trouble getting it to work. I can access the database from command line and also from Tora, but when I try with a web page I get an error 'could not find driver'
If I run phpinfo() inder PDO I see
PDO drivers no value

What do I need to do to get PDO drivers to work?

Thanks
Mick

User avatar
DougieLawson
Posts: 33813
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: MariaDB PDO Driver - No Value

Sat Dec 30, 2017 4:54 pm

Show us your table definition and the PDO code you're trying to run. Are you checking rowcount() before trying to process a possible non-existent result set?

mysqldump -d -u pi -p dbnamegoeshere # gives the data definition language for your tables in database dbnamegoeshere.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

User avatar
micksulley
Posts: 138
Joined: Sat Mar 03, 2012 11:48 am
Location: Melton Mowbray, England

Re: MariaDB PDO Driver - No Value

Sat Dec 30, 2017 5:06 pm

Here is the result from the dump

Code: Select all

[email protected]:~ $ mysqldump -d -u cabin -p cabin
Enter password: 
-- MySQL dump 10.16  Distrib 10.1.23-MariaDB, for debian-linux-gnueabihf (armv7l)
--
-- Host: localhost    Database: cabin
-- ------------------------------------------------------
-- Server version	10.1.23-MariaDB-9+deb9u1

/*!40101 SET @OLD_CHARACTER_SE[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @[email protected]@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `device`
--

DROP TABLE IF EXISTS `device`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `device` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(32) NOT NULL,
  `dev_class` varchar(5) DEFAULT NULL,
  `description` varchar(100) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `last_update_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER DEVICE_BI_TR before insert on device
for each row set 
NEW.Created_date = NOW(),
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER DEVICE_BU_TR before update on device
for each row set 
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;

--
-- Table structure for table `device_vals`
--

DROP TABLE IF EXISTS `device_vals`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `device_vals` (
  `device_val_id` int(11) NOT NULL AUTO_INCREMENT,
  `device_id` int(11) NOT NULL,
  `temperature` float DEFAULT '-99.9',
  `humidity` float DEFAULT '-99.9',
  `power` int(11) DEFAULT '0',
  `sensed` int(11) DEFAULT '0',
  `PIO` int(11) DEFAULT '0',
  `latch` int(11) DEFAULT '0',
  `tdate` datetime DEFAULT NULL,
  `loop_num` int(11) DEFAULT '0',
  PRIMARY KEY (`device_val_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `device_vals_sht`
--

DROP TABLE IF EXISTS `device_vals_sht`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `device_vals_sht` (
  `device_val_id` int(11) NOT NULL AUTO_INCREMENT,
  `device_id` int(11) NOT NULL,
  `temperature` float DEFAULT '-99.9',
  `humidity` float DEFAULT '-99.9',
  `power` int(11) DEFAULT '0',
  `sensed` int(11) DEFAULT '0',
  `PIO` int(11) DEFAULT '0',
  `latch` int(11) DEFAULT '0',
  `tdate` datetime DEFAULT NULL,
  `loop_num` int(11) DEFAULT '0',
  PRIMARY KEY (`device_val_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `device_vals_sngl`
--

DROP TABLE IF EXISTS `device_vals_sngl`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `device_vals_sngl` (
  `device_id` int(11) NOT NULL,
  `temperature` float DEFAULT '-99.9',
  `humidity` float DEFAULT '-99.9',
  `power` int(11) DEFAULT '0',
  `sensed` int(11) DEFAULT '0',
  `PIO` int(11) DEFAULT '0',
  `latch` int(11) DEFAULT '0',
  `tdate` datetime DEFAULT NULL,
  `loop_num` int(11) DEFAULT '0',
  PRIMARY KEY (`device_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `gpio`
--

DROP TABLE IF EXISTS `gpio`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `gpio` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(32) NOT NULL,
  `gpio` varchar(10) DEFAULT NULL,
  `pin` int(11) DEFAULT NULL,
  `description` varchar(100) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `last_update_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER GPIO_BI_TR before insert on gpio
for each row set 
NEW.Created_date = NOW(),
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER GPIO_BU_TR before update on gpio
for each row set 
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;

--
-- Table structure for table `gpio_vals`
--

DROP TABLE IF EXISTS `gpio_vals`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `gpio_vals` (
  `gpio_val_id` int(11) NOT NULL AUTO_INCREMENT,
  `gpio_device_id` int(11) NOT NULL,
  `val` int(11) DEFAULT NULL,
  `tdate` datetime DEFAULT NULL,
  `loop_num` int(11) DEFAULT '0',
  PRIMARY KEY (`gpio_val_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `htg_status`
--

DROP TABLE IF EXISTS `htg_status`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `htg_status` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `last_sys_on` datetime DEFAULT NULL,
  `last_sys_off` datetime DEFAULT NULL,
  `last_pwr_on` datetime DEFAULT NULL,
  `last_pwr_off` datetime DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `last_update_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER HTG_STATUS_BI_TR before insert on htg_status
for each row set 
NEW.Created_date = NOW(),
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER HTG_STATUS_BU_TR before update on htg_status
for each row set 
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;

--
-- Table structure for table `io_device`
--

DROP TABLE IF EXISTS `io_device`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `io_device` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(32) NOT NULL,
  `description` varchar(100) DEFAULT NULL,
  `mode` varchar(1) DEFAULT NULL,
  `channel` varchar(10) DEFAULT NULL,
  `parent` varchar(32) NOT NULL,
  `enabled` int(11) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `last_update_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER IO_DEVICE_BI_TR before insert on io_device
for each row set 
NEW.Created_date = NOW(),
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER IO_DEVICE_BU_TR before update on io_device
for each row set 
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;

--
-- Table structure for table `io_module`
--

DROP TABLE IF EXISTS `io_module`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `io_module` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(32) NOT NULL,
  `description` varchar(100) DEFAULT NULL,
  `enabled` int(11) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `last_update_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER IO_MODULE_BI_TR before insert on io_module
for each row set 
NEW.Created_date = NOW(),
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER IO_MODULE_BU_TR before update on io_module
for each row set 
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;

--
-- Table structure for table `io_module_vals`
--

DROP TABLE IF EXISTS `io_module_vals`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `io_module_vals` (
  `val_id` int(11) NOT NULL AUTO_INCREMENT,
  `module_id` int(11) NOT NULL,
  `output` int(11) DEFAULT NULL,
  `feedback` int(11) DEFAULT NULL,
  `status` int(11) DEFAULT NULL,
  `tdate` datetime DEFAULT NULL,
  `loop_num` int(11) DEFAULT '0',
  PRIMARY KEY (`val_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `io_module_vals_sngl`
--

DROP TABLE IF EXISTS `io_module_vals_sngl`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `io_module_vals_sngl` (
  `val_id` int(11) NOT NULL AUTO_INCREMENT,
  `module_id` int(11) NOT NULL,
  `output` int(11) DEFAULT NULL,
  `output_on` datetime DEFAULT NULL,
  `output_off` datetime DEFAULT NULL,
  `feedback` int(11) DEFAULT NULL,
  `feedback_on` datetime DEFAULT NULL,
  `feedback_off` datetime DEFAULT NULL,
  `status` int(11) DEFAULT NULL,
  `tdate` datetime DEFAULT NULL,
  `loop_num` int(11) DEFAULT '0',
  PRIMARY KEY (`val_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `io_vals`
--

DROP TABLE IF EXISTS `io_vals`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `io_vals` (
  `io_val_id` int(11) NOT NULL AUTO_INCREMENT,
  `io_device_id` int(11) NOT NULL,
  `sensed` int(11) DEFAULT '0',
  `PIO` int(11) DEFAULT '0',
  `latch` int(11) DEFAULT '0',
  `tdate` datetime DEFAULT NULL,
  `loop_num` int(11) DEFAULT '0',
  PRIMARY KEY (`io_val_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `io_vals_shrt`
--

DROP TABLE IF EXISTS `io_vals_shrt`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `io_vals_shrt` (
  `io_val_id` int(11) NOT NULL AUTO_INCREMENT,
  `io_device_id` int(11) NOT NULL,
  `sensed` int(11) DEFAULT '0',
  `PIO` int(11) DEFAULT '0',
  `latch` int(11) DEFAULT '0',
  `tdate` datetime DEFAULT NULL,
  PRIMARY KEY (`io_val_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `mem_log2`
--

DROP TABLE IF EXISTS `mem_log2`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mem_log2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tdate` datetime DEFAULT NULL,
  `active` varchar(32) DEFAULT NULL,
  `active_anon` varchar(32) DEFAULT NULL,
  `active_file` varchar(32) DEFAULT NULL,
  `anonpages` varchar(32) DEFAULT NULL,
  `buffers` varchar(32) DEFAULT NULL,
  `cached` varchar(32) DEFAULT NULL,
  `commitlimit` varchar(32) DEFAULT NULL,
  `committed_as` varchar(32) DEFAULT NULL,
  `dirty` varchar(32) DEFAULT NULL,
  `inactive` varchar(32) DEFAULT NULL,
  `inactive_anon` varchar(32) DEFAULT NULL,
  `inactive_file` varchar(32) DEFAULT NULL,
  `kernelstack` varchar(32) DEFAULT NULL,
  `mapped` varchar(32) DEFAULT NULL,
  `memfree` varchar(32) DEFAULT NULL,
  `memtotal` varchar(32) DEFAULT NULL,
  `pagetables` varchar(32) DEFAULT NULL,
  `shmem` varchar(32) DEFAULT NULL,
  `slab` varchar(32) DEFAULT NULL,
  `sreclaimable` varchar(32) DEFAULT NULL,
  `sunreclaim` varchar(32) DEFAULT NULL,
  `swapcached` varchar(32) DEFAULT NULL,
  `swapfree` varchar(32) DEFAULT NULL,
  `swaptotal` varchar(32) DEFAULT NULL,
  `vmallocchunk` varchar(32) DEFAULT NULL,
  `vmalloctotal` varchar(32) DEFAULT NULL,
  `vmallocused` varchar(32) DEFAULT NULL,
  `writeback` varchar(32) DEFAULT NULL,
  `local_ht_bt` varchar(32) DEFAULT NULL,
  `other_ht_bt` varchar(32) DEFAULT NULL,
  `disk_free` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `output_hist`
--

DROP TABLE IF EXISTS `output_hist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `output_hist` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `output_id` int(11) DEFAULT NULL,
  `t_on` tinyint(1) DEFAULT NULL,
  `t_off` tinyint(1) DEFAULT NULL,
  `date_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `params`
--

DROP TABLE IF EXISTS `params`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `params` (
  `param_id` int(11) NOT NULL AUTO_INCREMENT,
  `param_code` varchar(32) NOT NULL,
  `description` varchar(100) DEFAULT NULL,
  `param_val` int(11) DEFAULT NULL,
  `enabled` int(11) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `last_update_date` datetime DEFAULT NULL,
  `old_val` int(11) DEFAULT NULL,
  PRIMARY KEY (`param_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER PARAMS_BI_TR before insert on params
for each row set 
NEW.Created_date = NOW(),
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER PARAMS_BU_TR before update on params
for each row set 
NEW.old_val = OLD.param_val,
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;

--
-- Table structure for table `status`
--

DROP TABLE IF EXISTS `status`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `status` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `on_date` date DEFAULT NULL,
  `cal_date` date DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `last_update_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER STATUS_BI_TR before insert on status
for each row set 
NEW.Created_date = NOW(),
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER STATUS_BU_TR before update on status
for each row set 
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;

--
-- Table structure for table `timers`
--

DROP TABLE IF EXISTS `timers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `timers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(32) NOT NULL,
  `duration` int(11) DEFAULT NULL,
  `time_base` varchar(32) DEFAULT NULL,
  `complete` tinyint(1) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `last_update_date` datetime DEFAULT NULL,
  `description` varchar(100) DEFAULT NULL,
  `end_time` datetime DEFAULT NULL,
  `start_time` datetime DEFAULT NULL,
  `delay` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER TIMERS_BI_TR before insert on timers
for each row set 
NEW.Created_date = NOW(),
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`cabin`@`192.168.1.%`*/ /*!50003 TRIGGER TIMERS_BU_TR before update on timers
for each row set 
NEW.Last_update_date = sysdate() */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!40103 SET [email protected]_TIME_ZONE */;

/*!40101 SET [email protected]_SQL_MODE */;
/*!40014 SET [email protected]_FOREIGN_KEY_CHECKS */;
/*!40014 SET [email protected]_UNIQUE_CHECKS */;
/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;
/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;
/*!40101 SET [email protected]_COLLATION_CONNECTION */;
/*!40111 SET [email protected]_SQL_NOTES */;

-- Dump completed on 2017-12-30 17:02:44
[email protected]:~ $ 
My username is not pi, it is 'cabin', does that cause any complications?

User avatar
DougieLawson
Posts: 33813
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: MariaDB PDO Driver - No Value

Sat Dec 30, 2017 8:09 pm

Here's a starting point

Code: Select all

<?php
$sql  = 'SELECT `device_id`, `temperature`, `humidity`, `power`, `sensed`, `PIO`, `latch`, `tdate`, `loop_num` FROM `device_vals_sngl` WHERE 1';

$pdo = new PDO('mysql:host=localhost;dbname=forum','forum','forumsql');
?>
<H1>Device Single</h1>
<table border=1>
<th>Device ID</th><th>Temp</th>
<?php
try {
        foreach($pdo->query($sql) as $row) {
                echo "<tr><td>";
                echo $row['device_id'].'</td><td>'.$row['temperature'].'</td></tr>';
        }
} catch(PDOException $exc) {
        echo "SQL error" . $exc->getMessage();
}
?>
</table>
I'm puzzled why you have so many tables that look so alike. If you want to read the data from a table in a different format use VIEW.
https://dev.mysql.com/doc/refman/5.7/en ... -view.html
A VIEW can even include SQL to reduce a base table to a sub-set of data.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

User avatar
micksulley
Posts: 138
Joined: Sat Mar 03, 2012 11:48 am
Location: Melton Mowbray, England

Re: MariaDB PDO Driver - No Value

Sat Dec 30, 2017 9:11 pm

OK maybe my database is not good, that is something I can look at later. The point is that it all worked in MySQL but now does not in MariaDB. It looks to me that the problem is that PDO drivers are not enabled, but I don't know what to do about it.

User avatar
DougieLawson
Posts: 33813
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: MariaDB PDO Driver - No Value

Sat Dec 30, 2017 10:48 pm

I installed that stuff the easy way with sudo apt install phpmyadmin as that's using the PDO interface.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

User avatar
micksulley
Posts: 138
Joined: Sat Mar 03, 2012 11:48 am
Location: Melton Mowbray, England

Re: MariaDB PDO Driver - No Value - Fixed

Sat Dec 30, 2017 11:45 pm

That has fixed it!
Thanks Dougie

Return to “Other programming languages”

Who is online

Users browsing this forum: No registered users and 2 guests