doctrine-1.2

How to query NOT NULL with Doctrine?

℡╲_俬逩灬. 提交于 2019-12-01 02:29:21
I have table Test: Test: id | name 1 | aaa 2 | 3 | ccc 4 | aaa 5 | 6 | ddd I want result where name is NOT NULL: aaa ccc aaa ddd How can i get with: Doctrine_Core::getTable('Test')->findBy('name', NOTNULL??) <-doesnt working and in model with: $this->createQuery('u') ->where('name = ?', NOTNULL ???) <- doesnt working ->execute(); Try this: $this->createQuery('u') ->where('name IS NOT NULL') ->execute(); which is standard SQL syntax. Doctrine doesn't convert Null values into proper sql. Do it in Doctrine way, from query builder and Expr class. $qb = $entityManager->createQueryBuilder(); $result

How to escape LIKE %$var% with Doctrine?

点点圈 提交于 2019-11-29 01:53:31
I am making a Doctrine query and I have to do a wildcard match in the where clause. How should I escape the variable that I want to insert? The query I want to get: SELECT u.* FROM User as u WHERE name LIKE %var% The php code until now: $query = Doctrine_Query::create() ->from('User u') ->where(); What should come in the where clause? The variable I want to match is $name Mark E. Haase Nobody answered your question correctly, so I'll make a stab at it. ->where('u.name LIKE ?', array("%$name%")); ->where('u.username LIKE ?', '%'.$username.'%') Neither of these are safe. Let me explain a few

MYSQL incorrect DATETIME format

╄→гoц情女王★ 提交于 2019-11-28 09:01:02
I have an app with Doctrine 1 and I generate update_datetime fields for objects via new Zend_Date->getIso() . It worked just fine for years, but now I got a new notebook and Doctrine tries to insert a DATETIME fields as a string "2013-07-12T03:00:00+07:00" instead of normal MySQL datetime format "2013-07-12 00:00:00" which is totally weird. The very same code runs just fine on another computer. Everything is nearly identical – MySQL 5.6.12, PHP 5.3.15 on both. Any idea where should I look? Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[22007]:

How to escape LIKE %$var% with Doctrine?

家住魔仙堡 提交于 2019-11-27 16:16:03
问题 I am making a Doctrine query and I have to do a wildcard match in the where clause. How should I escape the variable that I want to insert? The query I want to get: SELECT u.* FROM User as u WHERE name LIKE %var% The php code until now: $query = Doctrine_Query::create() ->from('User u') ->where(); What should come in the where clause? The variable I want to match is $name 回答1: Nobody answered your question correctly, so I'll make a stab at it. ->where('u.name LIKE ?', array("%$name%")); -

MYSQL incorrect DATETIME format

匆匆过客 提交于 2019-11-27 02:34:28
问题 I have an app with Doctrine 1 and I generate update_datetime fields for objects via new Zend_Date->getIso() . It worked just fine for years, but now I got a new notebook and Doctrine tries to insert a DATETIME fields as a string "2013-07-12T03:00:00+07:00" instead of normal MySQL datetime format "2013-07-12 00:00:00" which is totally weird. The very same code runs just fine on another computer. Everything is nearly identical – MySQL 5.6.12, PHP 5.3.15 on both. Any idea where should I look?