zend-db

retrieve last updated column in mysql

北慕城南 提交于 2019-12-10 12:05:52
问题 I have a MySQL query that goes as follows (using Zend_Db): $sql = $handle->quoteInto("UPDATE board SET rank=rank+1 WHERE post_id=?", $postid); $handle->query($sql); (Rank isn't an auto-incrementing PK). I would like to now retrieve the value of rank without preforming another query. I've tried $handle->lastInsertId(); but it doesn't seem to work , since I didn't use MySQL's natural auto-incrementing method (I can't - rank is the rank of a post. I either ++ or -- it.) Any way to do this with

select queries with Zend_DB_Table

只谈情不闲聊 提交于 2019-12-10 10:49:51
问题 I have a code something like following class Application_Model_Company extends Zend_Db_Table_Abstract { protected $_name = 'companies'; private $id; private $name; private $shortName; private $description; public static function getAllCompanies() { $companyObj = new self(); $select = $companyObj->select()->order(array('name')); $rows = $companyObj->fetchAll($select); if($rows) { $companies = array(); foreach($rows as $row) { $company = new self(); $company->id = $row->id; $company->name =

How to connect to DB, when running via command line

点点圈 提交于 2019-12-09 14:54:43
问题 When I run zend framework project from browser, everything is OK, it connects to DB. When I run project from command line it can't connect to DB and it throws an error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Abstract.php:129 I have used Running a Zend Framework action from command line 's answers ( https://stackoverflow.com/a/4706966/457033 ) It's my

How to get Column Name With Zend DB

好久不见. 提交于 2019-12-09 09:01:56
问题 How to get Column Name With Zend DB 回答1: This is the correct answer, the older answers are wrong or outdated: $cols = $table->info(Zend_Db_Table_Abstract::COLS); 回答2: $metadata = $db->describeTable($tableName); $columnNames = array_keys($metadata); http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.list-describe 回答3: Previous answer applies only to version < 2. For current version of ZF (2.2) use: $table = new Zend\Db\TableGateway\TableGateway('table', $Dbadapter, new Zend\Db

Unable to delete a record through Zend_Db_Table_Abstract->delete()

房东的猫 提交于 2019-12-08 09:36:54
问题 I am trying to delete a record through a delete action using zend framework Model. i am still unable to figure out why its not deleting and the $model->delete() always returns zero. (0) this is my delete action code. public function deleteAction() { if ($this->getRequest()->isGet()) { $id = $this->getRequest()->getParam('id'); if (!empty($id)) { $id = $this->getRequest()->getPost('id'); $post = new Application_Model_Post(); if ($post->delete($id)) { $this->_helper->flashMessenger->addMessage(

How to use Zend Framework 2 with MS SQL Server on *nix?

元气小坏坏 提交于 2019-12-08 07:16:30
问题 What, if it exists, is the canonical way to use ZF2 with MS SQL Server on a non-Windows OS? From what I can tell from the documentation, only the Sqlsrv driver is officially supported, which only works on the Windows platform. In ZF1, we used the Pdo_Mssql adapter and specified the pdoType as dblib . I can't find any references to doing anything similar in ZF2. Apparently there was a Pdo\Mssql driver some time ago which was removed during a major refactoring, but I don't see a currently

Fatal exception in loading ini file

筅森魡賤 提交于 2019-12-07 20:37:14
问题 My project folder is demo, inside which I have the folders application, library and public. Inside the application folder, I have a folder named configs, inside which I have a file 'application.ini', which contains my database parameters. So, in the bootstrap.php which is in application directory, I set my database in Zend registry in a function called _initDbAdapter : $config = new Zend_Config_Ini('/demo/application/configs/application.ini', 'development'); Zend_Registry::set('config',

zf2 make a join between two different databases

故事扮演 提交于 2019-12-07 07:31:09
问题 I am trying to make a join between two tables placed in different databases with Zend Framework 2. The first table is called users and is stored in the database admin The second table is called hierarchy and is stored in the database customer I load the databases adapters in global.php return array( 'admin' => array( 'driver' => 'Pdo', 'dsn' => 'mysql:dbname=admin;host=localhost', 'driver_options' => array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'' ), ), 'customer' => array(

Zend db adapter mysqli or PDO_MYSQL

*爱你&永不变心* 提交于 2019-12-07 07:10:18
问题 I've seen several code samples that do this in application.ini resources.db.adapter = mysqli or resources.db.adapter = PDO_MYSQL What is the real difference between the two? Does it impact my code? when should I choose one or the other? 回答1: I developed a lot of the Zend_Db component for Zend Framework through the 1.0 release. It was the goal that the adapters function identically, or as close to it as could be supported by the PHP extension. The same set of unit tests can be run against both

like in where query in zend framework 2

ぃ、小莉子 提交于 2019-12-07 06:54:12
问题 I am using the Zend framework 2.x and facing the problem as I have search a lot. I want to use the like clause in query but each time gives the errors: Here is my efforts: $sql = new Sql($this->adapter); $select = $sql->select()->columns( array('user_profile_id', 'profile_login_name'))->from($this->table)->where->like( 'profile_login_name', '%'.$strSearch.'%'); echo $select->getSqlString(); die; but this gives the error: Fatal error : Call to undefined method Zend\Db\Sql\Where::getSqlString()