-
- 66 Posts
hello
i am trying to use xpdo new query function like
$query=$this->mxpdo->newQuery(’myclass’,array(
’col1’ => $postvars[’a’],
’col2’ => $postvars[’b’],
’col3:LIKE’ => ’%’.$postvars[’c’].’%’,
));
$cdata = $this->mxpdo->getCollection(’myclass’,$query);
but iam always getting error preparing sql statement for query... message
when i debug the query i found the bindings are not assigned to query
like select x from mytable where col1=? and col2=?
any idea why iam getting this error
please help me here
thanks
venu
-
- 66 Posts
thanks for your reply
yes iam getting the same problem with where clause
first i tried with $query->where(...) but when it dint worked i tied in other way that i mentioned above
but also in xpdocriteria iam getting the same problem
the variables are not binding with sql query
more details about the db
i am using another database in modxrevo
and intialied the xpdo in my class constructor like
$this->mxpdo=new XPDO("mysql:host=’localhost’;dbname=’mydb’", ’test’, ’test’);
$this->mxpdo->addPackage(’mypackage’,$this->config[’model_path’]);
the package and ORmaps are loading perfectly
not sure whats the mistake here
please help me
thanks
-
- 66 Posts
sorry for wasting your time
found the problem
it is in xpdo instantiation using "" insted of ’’
i wrote $mxpdo=new XPDO("mysql:host=’localhost’;dbname=’mydb’", ’test’, ’test’);
instead of
$mxpdo= new xPDO(’mysql:host=localhost;dbname=mydb’,’test’,’test’,’’);
but dont find any information about this in debug maps and tables are loading perfectly
so dint expected eroor is in constructor
anyway thanks for your reply
FYI, this occurred because the actual PDO connection is not made until the first query is executed.