Just started exploring the world of Aura :-) So please don't bite me. Trying to move to a next level in PHP programming.
So the first lesson task is to run a query agains a Mysql database. Here is the code i used:
<?php
include '../vendor/autoload.php';
// Init Aura
use Aura\SqlQuery\QueryFactory;
use Aura\Sql\ExtendedPdo;
$query_factory = new QueryFactory('Mysql');
// Init end
//
// Creating a $select for query: SELECT * FROM TEST_TRAVEL
$select = $query_factory->newSelect();
$select
->cols(array('*'))
->from('test_travel')
;
// Printing a query; it looks like SELECT * FROM `test_travel` - hmm looks good
echo $select->getStatement();
// PDO Connection
$pdo = new ExtendedPdo(
'mysql:host=localhost;dbname=test',
'user',
'userpass'
);
$sth = $pdo->prepare($select->getStatement());
echo '<br>';
// lets try to fetch sometinh
$result = $pdo->fetchOne($sth);
?>
[Mon Aug 03 06:59:07.813783 2015] [:error] [pid 25766] [client
2.92.128.236:50133] PHP Warning: PDO::prepare() expects parameter 1 to be string, object given in .../htdocs/vendor/aura/sql/src/ExtendedPdo.php on line 771
[Mon Aug 03 06:59:07.813898 2015] [:error] [pid 25766] [client
2.92.128.236:50133] PHP Fatal error: Call to a member function execute() on a non-object in .../htdocs/vendor/aura/sql/src/ExtendedPdo.php on line 748
[Mon Aug 03 07:09:51.271233 2015] [:error] [pid 25778] [client
2.92.128.236:50250] PHP Warning: PDO::prepare() expects parameter 1 to be string, object given in .../htdocs/vendor/aura/sql/src/ExtendedPdo.php on line 771
[Mon Aug 03 07:09:51.271348 2015] [:error] [pid 25778] [client
2.92.128.236:50250] PHP Fatal error: Call to a member function execute() on a non-object in .../htdocs/vendor/aura/sql/src/ExtendedPdo.php on line 748
Finally lost..