I have create a form class for editing deleting and add users to a database. If I want to edit a user how can I simply supply the information of the user to the form.
I use a Zend_Db_Table to get the data from the database.
This is the userForm class:
class UsersForm extends Zend_Form
{
public function init ()
{
$username...
Let's say have something like:
SELECT energy_produced, energy_consumed, timestamp1 AS timestamp FROM (
SELECT max(energy_produced) AS energy_produced, mid(timestamp, 1, 10) AS timestamp1 FROM tbl_energy
WHERE site_id = 1366 AND mid(timestamp, 1, 10) >= DATE_SUB(curdate(),INTERVAL 1 day)
group by mid(timestamp1, 1, 10)) AS e1
INNER JOIN...
I have a few tables that I've defined like the below examples:
class TableA extends Zend_Db_Table_Abstract
{
protected $_schema = 'schema1';
protected $_name = 'tablea';
}
class TableB extends Zend_Db_Table_Abstract
{
protected $_schema = 'schema2';
protected $_name = 'tableb';
}
...
Hi im using:
$data = array (
'next' => "NOW() + 5",
'interval' => $dom["USER"][0]["STATUSES_COUNT"][0]["data"],
'good' => $good,
'tries' => $p->tries + 1
);
$where = $service->getAdapter()->quoteInto('id = ?', $p->id);
$service->update($data, $where);
to insert something to a database using PHP...
I'm fairly new to the Zend Framework and MVC and I'm a bit confused by Zend_DB and the proper way to interact with the database.
I'm using the PDO MySQL adapter and have created some classes to extend the abstract classes:
class Users extends Zend_Db_Table_Abstract {
protected $_name = 'users';
protected $_primary = 'user_id';
...
Hi there
is there a way how to use Zend_Db relations for setting related objects?
I am looking for something like following code:
$contentModel = new Content();
$categoryModel = new Category();
$category = $categoryModel->createRow();
$category->setName('Name Category 4');
$content = $contentModel->createRow();
$content->setTitle(...
I'm having some problems translating this query to use ZF's Zend_Db_Select:
SELECT b.id, b.title, b.description
FROM memberships AS m
JOIN blogs AS b ON b.id = m.blog_id
WHERE m.user_id = ?
ORDER BY m.created
LIMIT 0, 30
(this query works and returns results)
Memberships is a link table between blogs and users. It's a simple | id ...
How to make PDO adapter run SET NAMES utf8 each time I connect, In ZendFramework.
I am using an INI file to save the adapter config data. what entries should I add there?
If it wasn't clear, I am looking for the correct syntax to do it in the config.ini file of my project and not in php code, as I regard this part of the configuration c...
Hi,
I'm using Zend Framework 1.7 with a MySQL 5.0 database for a project I'm doing. Part of the system is a longish form that asks a user for various dates (in dd/mm/yyyy format) as well as some integer fields.
In my MySQL table, all these fields have a default of null. When I come to save the form data with a function in my model (whic...
I have the following sql (a simplification of the real problem):
SELECT *
FROM t
WHERE myname LIKE '%{$input}%';
How do I escape the $input?
I can't use the quoteInto (unless I miss something).
As
$sql=$DB->quoteInto("SELECT *
FROM t
WHERE myname LIKE '%?%'",$input);
Will give me
SELECT *...
I would like to iterate over the data rows stored in a Zend_Db_Table_Rowset object and then drop/unset some of the rows, if they don't fulfil certain criteria.
I could use toArray() to get only the data rows from the object and then it would be easy to unset the rows I don't need. But since I want to keep my object for further use I don...
I have an array with information which looks more or less like this:
$data[] = array('content'=>'asd');
$data[] = array('content'=>'asdf');
And I want to add both entries into the Database.
$db->insert('table', $data);
does not add both entries. What am I doing wrong? Do I have to use Zend_ Db_Table?
$data = array('content'=>'asdf...
I have 2 databases that my site uses including a central user database that relates to other site-specific databases.
Sometimes it is adequate to call new User(array('db'=>'adapter1')); (but never convenient); other times, though, such as when declaring relationships between tables on different databases, there is no way to do this.
...
My sql statement is not working with Zend, its complaining about the Count(*) field... what am I doing wrong?
// get open/closed
$stmt = $db->query('SELECT status, count(*) as total FROM reported_issues WHERE date_reported >= '.$today.' AND status IN (0,1) GROUP BY status');
while ($row = $stmt->fetch())
{
switch ($row['status'])
...
Hi -
I currently use Zend_Db to manage my queries.
I've written already code that preforms queries like the one below:
$handle->select()->from('user_id')
->where('first_name=?', $id)
->where('last_name=?', $lname)
I've done this without sanitizing the input, assuming Zend_Db will. Does Zend do th...
hi all,
i want to output the query generated by Zend_Db_Table's select() statement for testing porposes but i dont know how.
...
Original Question:
I am currently using Zend Framework with Zend_Db_*, and I am selecting three random rows from a table:
$category->getTable()->select()->order(new Zend_Db_Expr('RAND()'))->limit('3')
Where $category is a Zend_Db_Table_Row. I would like to grab three random rows, but have those three rows ordered by the column named ...
Does anyone know of a way to group where clauses with Zend_Db? Basically I have this query
$sql = $table->select()
->where('company_id = ?', $company_id)
->where('client_email = ?', $client_email)
->orWhere('client_email_alt = ?', $client_email);
Which is giving me this:
SELECT `clients`.* FROM `clients` WHERE (company_id...
I understand that you can have class Users extends Zend_Db_Table_Abstract and class User extends Zend_Db_Table_Row_Abstract, setting the $_rowClass property of Users to User.
To create and save a new row, I only know how to do the following:
$users = new Users()
$user = $users->createRow();
$user->name = 'name';
$user->save();
Can yo...
I've recently started using Zend Framework (1.8.4), to provide admin tools for viewing the orders of a shopping cart site.
What I'd like to do is to efficiently create multiple model (Zend_Db_Table_Row_Abstract) objects from a single database result row.
The relationship is simple:
an Order has one Customer (foreign key order_custid...