zend-db

Zend_Db_Table UTF-8 Characters

Tables in my database are created with a correct UTF-8 charset like this: CREATE TABLE users ( id INT NOT NULL AUTO_INCREMENT, ... ... ... ... ... PRIMARY KEY (id) ) ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_slovak_ci; However, when I use Zend_Db_Table to fetch the data from the table with this method: public function getSingl...

Zend_Auth - Forced to use Zend_DB for quick installation/use?

Hello, i am thinking of using Zend_Auth as the Authentication "mechanism" (component) for a web site. After a quick look a realized that for Database Table Authentication i will also have to use the Zend_Db component. Has anyone tried this approach? Am i forced to use and/or extend/implement the Zend_DB methods/interfaces in order to ha...

Zend Framework: How should I unit test my Mapper in Zend_Db?

Hello, How would I test my mappers in Zend_Db? Each of my model will have 3 classes: The Model The Mapper The DbTable Here is my Unit Test: <?php // Call Model_BugTest::main() if this source file is executed directly. if (!defined("PHPUnit_MAIN_METHOD")) { define("PHPUnit_MAIN_METHOD", "Model_ArtistTest::main"); } require_once...

Zend DB fetchAll(): where clause array with IN operator

I'm selecting records from a database using the equivalent of this query: SELECT * FROM reports WHERE user_id IN (3, 6, 22); The function calling fetchAll() has an argument that's an array of the user IDs, and this call works just fine: $resultSet = $this->getDbTable()->fetchAll('user_id IN (' . implode(', ', $userIds) . ')'); Howe...

How to create proper UPDATE query using NOW() ?

What's the way of building "UPDATE table SET date = NOW() WHERE id = 1" query ? $table->update(array('date' => 'NOW()'), 'id = 1'); Above code doesn't work properly. ...

Zend DB and Conditional Case Statements

Hey, I have a zend app that displays a league table of race results. The basic process is to determine the list of events to be included, and then dynamically add a set of columns to a SQL query. My initial implementation is rather rubbish and i want to refector it. I manually build up a string of SQL and at the very end call db->fetch(...

how to call stored procedure on zend framework

how to call mysql stored procedure on zend framework? any body may give an example? thanks ...

Lots and lots of joins in a Zend Query, hopefully just a slight tweak

Apologies for all this code, anyhow Im re-working a query into the Zend query way of working, this is what I have so far: $db = Zend_Registry::get ( "db" ); $stmt = $db->query(' SELECT recipe_pictures.picture_id, recipe_pictures.picture_filename, course.course_name, cuisines.name, recipes.id, recipes.Title, recipes.Method,...

Zend_Db_Profiler not logging db connection time?

Following the sample code on http://framework.zend.com/manual/en/zend.db.profiler.html I have set up db profiling of my Zend Framework app. application.ini: db.profiler.enabled = true View Helper: $totalTime = $profiler->getTotalElapsedSecs(); $queryCount = $profiler->getTotalNumQueries(); $longestTime = 0; $longestQuery = nul...

Zend_Db_Table_Row_Abstract returns NULL -- PHP pukes

My apologies up front for being a) a newbie and b) almost certainly not giving enough info. So I have app that uses ZF to fetch data from MySQL and display it to the user. The user can select a row of data and fetch additional information (username, hostname, etc...). I'm having an issue with PHP puking when ZF returns null data from ...

zend-framework navigation

i have this xml file for Creating a container , if i want create a db for save this items and and create container from db how should i do ? <?xml version="1.0" encoding="utf-8"?> <config> <nav> <logout> <label>logout</label> <controller>authentication</controller> <action>logout</actio...

Zend DB: How to find the actual amount of affected rows with INSERT ON DUPLICATE KEY?

$db->update() returns the affected amount of rows. There is no Zend_DB method for insert ... on duplicate key update ..., so one should use the query() method: $result = $db->query('INSERT INTO table(key, field) SELECT val1, val2 FROM table as t2 ON DUPLICATE KEY UPDATE field = VALUES(field)'); To find out the amount of affected or in...

Get all model details in zend.

Hi, I have one doubt in zend framework. I need all model details from project which i have done in zend framework. Is there any possibility to get all model details in zend framework. Please help me.. Thanks and regards, Prasanth P ...

Zend DB returning NULL value

I have the following query that extends from Zend_DB_Table_Abstract $select = $this->select() ->from('expense_details', array('SUM(expense_details_amount) AS total')) ->where('YEAR(expense_details_date) = ?', '2010') ->where('MONTH(expense_details_date) = ?', '01') ->where('expens...

Zend_Db Enum Values [Closed]

I find this solution $metadata = $result->getTable()->info('metadata'); echo $metadata['Continent']['DATA_TYPE']; Hi, I want to get enum values in Zend_Db. My Code: $select = $this->select(); $result = $select->fetchAll(); print_r($result->getTable()); Output: Example Object ( [_name] => country [query] => Zend_Db_Table_Se...

Optimising (My)SQL Query

I usually use ORM instead of SQL and I am slightly out of touch on the different JOINs... SELECT `order_invoice`.* , `client`.* , `order_product`.* , SUM(product.cost) as net FROM `order_invoice` LEFT JOIN `client` ON order_invoice.client_id = client.client_id LEFT JOIN `order_product` ON order_invoice....

Zend Database Adapter - Complex MySQL Query

I have defined a function in my Navigation model that executes a query, and I was wondering if there's a more "Zendy" way of generating/executing the query. The query I'm using was proposed by Bill Karwin on another thread here for setting arbitrary record order. I tried using a prepared statement, but the values in the SIGN() function...

How do I add complex where clause to Zend Table Select?

I searched the Web and could not find anything that would show me a good solid example. My question is basically this: How do I convert this: SELECT * FROM table WHERE ((a = 1 AND b = 2) OR (c = 3 OR c = 4)) AND d = 5; To Zend syntax similar to this: $this ->select() ->from($this->_schema.'.'.$this->_name) ->where('a = ?', '1'); ...

Zend Framework how to echo value of SUM query

Hello, I created a query for the zend framework, in which I try to retrieve the sum of a column, in this case the column named 'time'. This is the query I use: $this->timequery = $this->db_tasks->fetchAll($this->db_tasks->select()->from('tasks', 'SUM(time)')->where('projectnumber =' . $this->value_project)); $this->view->sumtime = $t...

Selecting arbitrary strings with Zend DB Select?

I am using the fluent interface to create a Zend DB Select object/query. As part of the query, I would like to select an arbitrary string, like "SELECT 'foo' AS 'type' FROM ...". foo is not a column, it's just a string literal. When I select an arbitrary number, the query works as expected. When I change it to a string, Zend tries to tr...