zend-db

Zend Framework: Multidb fails to initialize

我的梦境 提交于 2019-12-04 17:57:39
This used to work but after some modifications by the other programmers it just fails to work. I have this code on my Bootstrap: protected function _initDatabase () { $resource = $this->getPluginResource('multidb'); $resource->init(); Zend_Registry::set('gtap', $resource->getDb('gtap')); Zend_Registry::set('phpbb', $resource->getDb('phpbb')); } Upon loading, this error shows up: Fatal error: Call to a member function init() on a non-object in /var/www/gamebowl3/application/Bootstrap.php on line 105 My php.ini has this entry on tis include_path: .:/usr/share/php:/etc/apache2/libraries and the i

Zend_Db_Profiler log to file

倾然丶 夕夏残阳落幕 提交于 2019-12-04 13:47:36
问题 Is there a simple way to log to queries to a file? I have Firebug profiling working no problem with: resources.db.params.profiler.enabled = "true" resources.db.params.profiler.class = "Zend_Db_Profiler_Firebug" It would be nice to log this to a file with out writing a bunch of code. Is there a class I can swap out with Zend_Db_Profiler_Firebug? UPDATE: See my answer below. 回答1: As of ZF 1.11.11 there is no built in profiler class that will log queries to a file. Currently, FireBug is the only

Handeling M-N Relationship in Zend Framework 2

為{幸葍}努か 提交于 2019-12-04 12:47:49
With beta4 and latest beta5 the DB-Feature-Implementation appears to have pretty much finished. There's a couple of tutorials out there how to handle a single Database using the TableGateway Pattern, but it appears there is none for handling M-N-Relationships. In ZF1 we had findDependantRowset() on the TableGateway which was kind of dirty, as this simply was a second Query to the databse which pretty much isn't always neccessary. In ZF2 i expected there to be a way to have good Joins mapping to specified models, but i can't find anything within the code. Maybe i'm blind, maybe there really isn

Zend Form Edit and Zend_Validate_Db_NoRecordExists

余生长醉 提交于 2019-12-04 11:18:27
问题 I am slowly building up my Zend skills by building some utility websites for my own use. I have been using Zend Forms and Form validation and so far have been happy that I have been understanding the Zend way of doing things. However I am a bit confused with how to use Zend_Validate_Db_NoRecordExists() in the context of an edit form and a field that maps to database column that has to be unique. For example using this simple table TABLE Test ( ID INT AUTO_INCREMENT, Data INT UNIQUE ); If I

Zend_Db subquery

烈酒焚心 提交于 2019-12-04 07:43:45
I've been trying to construct a sql query with ZendFW, but I cant seem to get it to function like I want to (or function at all). This is the query that works that I'm trying to build with zend_db select() SELECT tc.trip_title, td.ID, td.trip_id, (SELECT count(*) FROM 'trips_invites' ti WHERE ti.destination_id=td.ID AND ti.accepted ='NR') AS "pending_invites" FROM `trips_current` AS `tc`, `trips_data` AS `td` WHERE (tc.ID=td.trip_id) AND (tc.creator_id = '1') ORDER BY `trip_id` ASC What I can't figure out is how to properly get that subquery in there, and nothing I try seems to work. Any help

Is there a way to get the number of records from a query with Zend-framework?

≡放荡痞女 提交于 2019-12-04 05:06:24
Given my generic select below, is there a way to get the number of records returned from a query with Zend Framework? $row++ in a loop is not acceptable for my solution as I am using paging (though its not in my sample). I also DO NOT want to add another query with "Count(*)". $query = "Select * from Users where active = 1"; $stmt = $db->query($query); $noOfRows = ???; while ($row = $stmt->fetch()) { // processing } Use fetchAll() fetchAll returns an array, so you can do something like this: $rows = $db->fetchAll("select ..."); $numRows = sizeof($rows); foreach ($rows as $row) { // process

Zend framework $db->update result

試著忘記壹切 提交于 2019-12-04 04:37:20
问题 Zend_Db_Adapter::update() returns the number of rows affected by the update operation. What is best way to determine if the query was successful? $data = array( 'updated_on' => '2007-03-23', 'bug_status' => 'FIXED' ); $n = $db->update('bugs', $data, 'bug_id = 2'); 回答1: $data = array( 'updated_on' => '2007-03-23', 'bug_status' => 'FIXED', ); $n = 0; try { $n = $db->update('bugs', $data, 'bug_id = 2'); } catch (Zend_Exception $e) { die('Something went wrong: ' . $e->getMessage()); } if (empty(

Executing multiple join with expressions on Zend Framework 2

牧云@^-^@ 提交于 2019-12-04 04:25:43
Actually I'm working on a project and I'm looking on how Zend Framework 2 handle complex queries (expecially on how to join n:m tables and how to use GROUP_CONCAT and other functions). Do you know the best practice to execute this query: SELECT o. * , x.group_one, x.group_two FROM table_one AS o LEFT JOIN ( SELECT r.fk1, GROUP_CONCAT( t.field_one ) AS group_one, GROUP_CONCAT( t.field_two ) AS group_two FROM table_three AS r INNER JOIN table_two AS t ON r.fk2 = t.id GROUP BY r.fk1 ) AS x ON o.id = x.fk1 LIMIT 0 , 20; using this db schema: -- -- Database: `table-test-1` -- -- -------------------

MasterSlaveFeature How-To

半腔热情 提交于 2019-12-03 16:27:24
I currently have my Db Models using AbstractTableGateway and all my select/insert/update/delete queries are working just fine. But now I would like to add the MasterSlaveFeature and I'm a bit confused on how to do this. The documentation doesn't exactly give a good example: http://zf2.readthedocs.org/en/latest/modules/zend.db.table-gateway.html#tablegateway-features I currently have this setup: namespace Login\Model; use Zend\Db\TableGateway\Feature\MasterSlaveFeature; use Zend\Db\TableGateway\Feature\FeatureSet; use Zend\Db\TableGateway\AbstractTableGateway; use Zend\Db\Sql\Select; use Zend

Tool That Convert mySQL Query To Zend FrameWork Query

自闭症网瘾萝莉.ら 提交于 2019-12-03 13:44:46
问题 Is there any Online Web Tool that Convert mySQL Query To Zend FrameWork Query. that is i type mySql Query and the Tool Convert it to Zend FrameWork equivalent Query 回答1: You don't need a tool for this. Within Zend Framework's Zend_Db, component, you can do: $stmt = $db->query($sql); If $sql is a select, then you can retrieve the data with: $rows = $stmt->fetchAll(); Alternatively, ZF is just a PHP framework, so there's nothing stopping you continuing to use PDO or mysqli directly. 来源: https:/