zend-db

Zend Framework: How to find a table row by the value of a specified column?

I am implementing my model exactly like the quickstart guide. In my model I am trying to implement a findByToken() method. The current find() method accepts an $id parameter, but I want to find by the value of a different column. //excerpt from the quickstart guide public function find($id, Default_Model_Guestbook $guestbook) { $re...

Zend Framework, access denied to my database, but only under certain wi-fi connections?

This is the second time that I've noticed this... I am running my Zend Framework application on my laptop, but connecting to my remote database. It works fine most of the time (from home, and other places). But this is the second time that I get an error message from my application: SQLSTATE[28000] [1045] Access denied for user 'databa...

Help With Zend_Db_Stmt

I have a little problem with the Zend_Db_Stmt. This works: $sql = " SELECT * FROM bugs"; $stmt = $this->_getDb()->query($sql); return $stmt->fetchAll(); But I am trying to make sure the PDO gets used to query the database so I tried this: $sql = "SELECT * FROM bugs"; $stmt = new Zend_Db_Statement_Pdo($this...

zend framework zend_db: what does it provide to escape sql parameters

what does zend framework provides in order to escape user input into a query string ? ...

Get first UTF-8 char from string and save in DB

I have a problem with inserting a letter that is not an A-Z char. For example: $fullTag = 'świat'; A 'letter' should contains ś $data = array( 'full_tag' => $fullTag, 'count' => 1, 'letter' => $fullTag[0], ); But when I execute $table->insert($data);, it inserts me as letter an empty string. If I set instead of ...

Help With Select Query In ZF

Ok. This version of select works: $select = $this->select(); $select->setIntegrityCheck(false); $select->from(array('u' => $this->_name), array('u.id', 'u.username', 'u.avatar_path', '(SELECT COUNT(*) FROM media WHERE user_id = u.id) media_count')); $where = "u.status = 'active' ...

Extending Zend_Db

I apologize if my title is a bit misleading and it turns out that it's some other class under Zend_Db. I use the following method of extracting data from a MSSQL: // $_config contains information about how to connect to my MSSQL server $config = new Zend_Config($_config); $db = Zend_Db::factory($config->database); $sql = "SELECT * FRO...

How to set current user in View?

I am using Zend Framework. I want the current user (if logged in) to always be available to the view. In my Bootstrap.php file I currently have: function _initViewHelpers() { $this->bootstrap('layout'); $layout = $this->getResource('layout'); $view = $layout->getView(); // <snip> $view-> set some stuff $v...

Strange error with zend frame work

Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'SQLSTATE[28000] [1045] Access denied for user 'liveaide_dbuser1'@'lynx-u.znetindia.net' (using password: YES)' in /home/liveaide/public_html/aider20test/zyberops/library/Zend/Db/Adapter/Pdo/Abstract.php:144 Stack trace: #0 /home/liveaide/public_html/aider20test/zyb...

ZEND FW : Joining two tables from different databases

I want to join two tables in differenet databases on the same server. Could someone tell me how I could do this in Zend Frameworks Db adapter? ...

Dwoo does not echo strings with utf8 characters

Hello ! I have got a strange problem with Zend Framework - I fetch data from MySql table that is set to utf8_general_ci. I inserted some data with polish fonts like ś ę ż... and push that data to view (Dwoo). {foreach $units unit} <tr> <td>{$unit.id_unit}</td> <td>{$unit.name}</td> </tr> ...

Zend Framework: How to include an OR statement in an SQL fetchAll()

I am trying to build the following SQL statement: SELECT users_table.*, users_data.first_name, users_data.last_name FROM users_table INNER JOIN users_data ON users_table.id = user_id WHERE (users_table.username LIKE '%sc%') OR (users_data.first_name LIKE '%sc%') OR (users_data.last_name LIKE '%sc%') I have the following c...

Zend_Db_Table fetchAll and column names

I'm testing Zen_DB and Zend_DB_Table and I'm facing a problem: Let's say I've got two tables table A(id, title) table B(id, title) If I write something like $db = $this->getDbTable()->getAdapter(); $query = "SELECT A.*, B.* FROM A INNER JOIN B on A.id = B.id" $stmt = $db->query($query); $rows = $stmt->fetchAll(); each re...

Zend Framework: Zend_DB Error

Hi, I'm trying to learn ZF, but got strange error after 20 minutes :) Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'Configuration array must have a key for 'dbname' that names the database instance' What does this error mean? I got DB information in my config file: resources.db.adapter=pdo_mysql resources...

Zend_Db order by field Value

I'm outputting the contents of a select menu from a model using this: $select = $this->select(); $select->order('name'); return $this->fetchAll($select); However, what i want to do is order by a specific value, and then by the name column. The SQL would look like this: SELECT * FROM `names` ORDER BY `name` = 'SomeValue' DESC,`name` ...

Updating single database cell in Zend Framework Model

Simple one hopefully, is there a specific way i should be updating a single database value using a model in Zend Framework. I currently do this: class Model_MyModel extends Zend_Db_Table_Abstract { $_name = 'table'; public function updateSetting($id,$status) { $data = array( 'status' => $status )...

Zend Form Edit and Zend_Validate_Db_NoRecordExists

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 an...

Zend Db Select ? Substitution in join* condition.

It doesn't look like there's any parameter substitution in Zend_Db_Select's on clause. It's highly annoying that I can't just do something like: $select->joinLeft('st_line_item','st_line_item.order_id = st_order.id and st_line_item.status = ?') So what's the idiomatic alternative that works within the fluent interface? I could do som...

Zend Framework zend_db_select ORDER

$select->where('MATCH(text,phone,phone2,email,email2,www,gadi,augums,skype) AGAINST(?)',$searching_string); $select->order('MATCH(text,phone,phone2,email,email2,www,gadi,augums,skype) AGAINST(?) DESC',$searching); Getting error: Message: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound The problem seems in...

Zend_db junction table join query

Hi guys, Not sure why I can't figure this one out. Basically, I have two tables with a many-to-many relationship so I have a junction table inbetween them. For an example, consider the following database schema: Restaurant (id, restaurant_name, suburb) RestaurantCuisine (restaurant_id, cuisine_id) Cuisine (id, cuisine_name) So, ma...