Re: [fw-general] Zend_Db_Table

2011-08-22 Thread Konr Ness
How do you know it does not return anything. What does count($drawings)
equate to?

Do you receive any errors?

Are you sure you have your DB config set properly and have permissions to
the DB?

I am not familiar with Firebird, but you should be able to use Zend_Db to
make SQL queries directly to the database like so:

$drawingModel-getAdapter()-fetchAll('SELECT * FROM `DRAWINGS`');

If that doesn't return the values you expect then there is probably a
configuration problem with your DB.

Konr

On Fri, Aug 19, 2011 at 1:24 PM, Steve Rayner srayne...@googlemail.comwrote:

 What am I doing wrong here;


 $drawingModel = new Spares_Model_Drawings();

 $drawing = $drawingModel-find(2);

 This does not return any rows even though there is a row with a primary key
 of 2.

 This is my model;

 class Spares_Model_Drawings *extends *Zend_Db_Table_Abstract{

protected $_name = 'DRAWINGS';

protected $_primary = 'DRAWING_REF';

 }

 My database is Firebird. I am using Zend Framework 1.10.0



Re: [fw-general] Zend_Db_Table with multiple databases

2009-09-17 Thread troels knak-nielsen
Thanks - That was useful indeed.

--
troels

On Wed, Sep 16, 2009 at 11:46 PM, Paul M Jones pmjone...@gmail.com wrote:

 On Sep 16, 2009, at 14:02 , troels knak-nielsen wrote:

 Hi.

 I'm looking into replacing a legacy system with Zend_Db + subpackages
 (Zend_Db_Table and friends), but I'm running into some problems. The
 setup we have is a master/slave. For offloading the main server all
 read queries are channelled to the slave, while all write queries are
 sent to the main server. The current library supports this by allowing
 each method to fetch the appropriate link. From what I can see, there
 is no direct support for such a thing in Zend_db_Table, but I can see
 a couple of possible flex points in the framework.

 Before I start off a tangent myself, I was wondering if anybody else
 have tried something like this?

 Hi Troels,

 You may find this earlier thread useful:

  http://www.nabble.com/Best-practice-for-Master-Slave-Db-w--ZF--td24179039.html

 In particular there is this bit about Solar, which obviously is not Zend
 Framework but may provide useful hints.

  http://www.nabble.com/Re%3A-Best-practice-for-Master-Slave-Db-w--ZF--p24204672.html

 selfpromotion

 This is as opposed to Solar's MysqlReplicated adapter, the SVN trunk
 version of which works automatically.  Yes, it examines the first few
 characters of the SQL statement to determine whether it should pick a
 master or a slave, which is not exactly a big performance drain.  It
 also manages GET-after-POST situations, so that if you insert or
 update on one request, the very next request *also* uses the master
 (even for reads), to allow time for data propagation to slaves.
 Finally, you can switch back and forth between replicated and non-
 replicated environments without changing your application code.

 See more here:

   http://solarphp.com/blog/read/19-adapter-for-master-slave-my-sql-setups

 /selfpromotion






 --

 Paul M. Jones
 http://paul-m-jones.com/







Re: [fw-general] Zend_Db_Table with multiple databases

2009-09-16 Thread Paul M Jones


On Sep 16, 2009, at 14:02 , troels knak-nielsen wrote:


Hi.

I'm looking into replacing a legacy system with Zend_Db + subpackages
(Zend_Db_Table and friends), but I'm running into some problems. The
setup we have is a master/slave. For offloading the main server all
read queries are channelled to the slave, while all write queries are
sent to the main server. The current library supports this by allowing
each method to fetch the appropriate link. From what I can see, there
is no direct support for such a thing in Zend_db_Table, but I can see
a couple of possible flex points in the framework.

Before I start off a tangent myself, I was wondering if anybody else
have tried something like this?


Hi Troels,

You may find this earlier thread useful:

  http://www.nabble.com/Best-practice-for-Master-Slave-Db-w--ZF--td24179039.html

In particular there is this bit about Solar, which obviously is not  
Zend Framework but may provide useful hints.


  
http://www.nabble.com/Re%3A-Best-practice-for-Master-Slave-Db-w--ZF--p24204672.html


selfpromotion

This is as opposed to Solar's MysqlReplicated adapter, the SVN trunk
version of which works automatically.  Yes, it examines the first few
characters of the SQL statement to determine whether it should pick a
master or a slave, which is not exactly a big performance drain.  It
also manages GET-after-POST situations, so that if you insert or
update on one request, the very next request *also* uses the master
(even for reads), to allow time for data propagation to slaves.
Finally, you can switch back and forth between replicated and non-
replicated environments without changing your application code.

See more here:

   http://solarphp.com/blog/read/19-adapter-for-master-slave-my-sql-setups

/selfpromotion







--

Paul M. Jones
http://paul-m-jones.com/






Re: [fw-general] Zend_Db_Table: Having one single class for intersection tables

2009-07-13 Thread Ralph Schindler
This is difficult in the current iteration of Zend_Db_Table since 
Zend_Db_Table's only use case requires each table name to implemented as 
a class that extends Zend_Db_Table.


In ZF 1.9, I have implemented a feature where Zend_Db_Table can be used 
as a concrete instance.  When this drops, you'll be able to configure 
your tables in a deinfition and expect them to work without extending 
Zend_Db_Table


The code is here:
http://framework.zend.com/svn/framework/standard/branches/user/ralph/ZendDbTable/

and the feature request is here:
http://framework.zend.com/issues/browse/ZF-3486

Stay tuned,
-ralph



pifoux2000 wrote:

Hello all,

my application is composed of a lot of several modules. Each module
corresponds to a table in the database. Basically each module can be linked
to every other module in many to many relationship.

This way when defining the tables in the Zend Framework, everytime I add the
definition class of a new module, i need to add a definition class of each
intersection tables as well.

Let's say I have four modules: M1, M2, M3, M4... for each of them I need to
have 3 intersection tables   ie a total of 12 tables. 


I am looking for a way to have one generic class for defining these
intersection tables.

Has anyone any clue on how to achieve this?

Thank you very much for your answers!


Re: [fw-general] Zend_Db_Table Relationships

2009-07-06 Thread Ralph Schindler


In situations where I have auxiliary and/or errata tables (basically a 
1-1 relationship), I would look into peering to those rows via the 
findParentRow($parentTable) method rather than finding as a DependentRowset.


http://framework.zend.com/manual/en/zend.db.table.relationships.html#zend.db.table.relationships.fetching.parent

It is modeled effectively the same way, but you are using a different 
approach for finding the actual Row.


Let me know if that helps!
-ralph



Now I have it working for the websites and keywords but cannot get the 
isp_partners_aux to work.  The issue seems to be that when I do the 
findDependantRowset it does not get any data from the isp_partners_aux 
table, rather it only contains the data from the isp_partners table. 
 There is only 1 row in each table that will match.  The aux table is 
just an external table that holds data about isp_partners such as the 
username, etc.  Below is my controller followed by my model classes and 
then the output.





Re: [fw-general] Zend_Db_Table Relationships

2009-07-06 Thread Joseph Crawford

Ralph,

Doing it that way would require me to instantiate the  
Model_DbTable_ISPPartnersAux() class and that is not how I have it  
setup.


Theoretically I should be able to instantiate the Partner model and  
say now find all rowsets that are in the dependent table based on the  
common id.  I fixed a few things in the code so here is what I have now.


I did some debugging by adding echo $select-__toString() in my Zend/ 
Db/Table/Abstract.php fetchRow method and found that the sql query is  
just this.


SELECT `isp_partners`.* FROM `isp_partners`

?php
class KeywordsController extends Zend_Controller_Action
{

public function init()
{
/* Initialize action controller here */
}

public function indexAction()
{
$this-view-headTitle('Keyword Management', 'APPEND');
$partners   = new Model_DbTable_ISPPartners();
$partners_aux   = new Model_DbTable_ISPPartnersAux();

$partner = $partners-fetchRow(code = 'red');
// THIS WORKS FINE WHEN NOT COMMENTED
//$results = $partner- 
findManyToManyRowset('Model_DbTable_ISPKeywords',  
'Model_DbTable_ISPWebsites');


// THIS DOES NOT SEEM TO GET HIT OR SOMETHING.
$aux_data = $partner- 
findDependentRowset('Model_DbTable_ISPPartnersAux', 'PartnersAux');

//echo 'pre'.print_r($results, true).'/pre'; exit;
$this-view-results = $results;

}
}

?php

/**
 * ISPPartners
 *
 * @author jcrawford
 * @version
 */

class Model_DbTable_ISPPartners extends Zend_Db_Table_Abstract {
/**
 * The default table name
 */
protected $_name = 'isp_partners';
protected $_primary = array('isp_id');

protected $_dependentTables = array('Model_DbTable_ISPPartnersAux');

protected $_referenceMap = array(
'PartnersAux'   =   array(
'columns'   =   array('isp_id'),
'refTableClass' =   
'Model_DbTable_ISPPartnersAux',
'refColumns'=   array('isp_id')
)
);
}

?php
class Model_DbTable_ISPPartnersAux extends Zend_Db_Table_Abstract
{
/**
 * The default table name
 */
protected $_name = 'isp_partners';
protected $_primary = array('isp_id');

protected $_referenceMap = array(
'Partners'  =   array(
'columns'   =   array('isp_id'),
'refTableClass' =   
'Model_DbTable_ISPPartners',
'refColumns'=   array('isp_id')
)
);

}



On Jul 6, 2009, at 1:19 PM, Ralph Schindler wrote:



In situations where I have auxiliary and/or errata tables (basically  
a 1-1 relationship), I would look into peering to those rows via the  
findParentRow($parentTable) method rather than finding as a  
DependentRowset.


http://framework.zend.com/manual/en/zend.db.table.relationships.html#zend.db.table.relationships.fetching.parent

It is modeled effectively the same way, but you are using a  
different approach for finding the actual Row.


Let me know if that helps!
-ralph

Now I have it working for the websites and keywords but cannot get  
the isp_partners_aux to work.  The issue seems to be that when I do  
the findDependantRowset it does not get any data from the  
isp_partners_aux table, rather it only contains the data from the  
isp_partners table.  There is only 1 row in each table that will  
match.  The aux table is just an external table that holds data  
about isp_partners such as the username, etc.  Below is my  
controller followed by my model classes and then the output.







Re: [fw-general] Zend_Db_Table Relationships

2009-07-06 Thread Joseph Crawford
I did some debugging by also adding the echo $select-__toString() in  
the /Zend/Db/Table/Row/Abstract.php on line 914 which is in the  
findDependentRowset method.


It seems to be outputting the same exact sql query

SELECT `isp_partners`.* FROM `isp_partners`

So for some odd reason it is not getting the dependent rowset rather  
doing the same query and I am not sure why :(


Thanks,
Joseph Crawford


On Jul 6, 2009, at 1:19 PM, Ralph Schindler wrote:



In situations where I have auxiliary and/or errata tables (basically  
a 1-1 relationship), I would look into peering to those rows via the  
findParentRow($parentTable) method rather than finding as a  
DependentRowset.


http://framework.zend.com/manual/en/zend.db.table.relationships.html#zend.db.table.relationships.fetching.parent

It is modeled effectively the same way, but you are using a  
different approach for finding the actual Row.


Let me know if that helps!
-ralph

Now I have it working for the websites and keywords but cannot get  
the isp_partners_aux to work.  The issue seems to be that when I do  
the findDependantRowset it does not get any data from the  
isp_partners_aux table, rather it only contains the data from the  
isp_partners table.  There is only 1 row in each table that will  
match.  The aux table is just an external table that holds data  
about isp_partners such as the username, etc.  Below is my  
controller followed by my model classes and then the output.







Re: [fw-general] Zend_Db_Table Relationships

2009-07-06 Thread Joseph Crawford
Please dis-reguard this question, i am just an idiot and had the table  
name incorrect in my AUX model class.


Thanks,
Joseph Crawford

On Jul 6, 2009, at 1:38 PM, Joseph Crawford wrote:

I did some debugging by also adding the echo $select-__toString()  
in the /Zend/Db/Table/Row/Abstract.php on line 914 which is in the  
findDependentRowset method.


It seems to be outputting the same exact sql query

SELECT `isp_partners`.* FROM `isp_partners`

So for some odd reason it is not getting the dependent rowset rather  
doing the same query and I am not sure why :(


Thanks,
Joseph Crawford


On Jul 6, 2009, at 1:19 PM, Ralph Schindler wrote:



In situations where I have auxiliary and/or errata tables  
(basically a 1-1 relationship), I would look into peering to those  
rows via the findParentRow($parentTable) method rather than finding  
as a DependentRowset.


http://framework.zend.com/manual/en/zend.db.table.relationships.html#zend.db.table.relationships.fetching.parent

It is modeled effectively the same way, but you are using a  
different approach for finding the actual Row.


Let me know if that helps!
-ralph

Now I have it working for the websites and keywords but cannot get  
the isp_partners_aux to work.  The issue seems to be that when I  
do the findDependantRowset it does not get any data from the  
isp_partners_aux table, rather it only contains the data from the  
isp_partners table.  There is only 1 row in each table that will  
match.  The aux table is just an external table that holds data  
about isp_partners such as the username, etc.  Below is my  
controller followed by my model classes and then the output.









Re: [fw-general] Zend_Db_Table Relationships

2009-07-06 Thread Ralph Schindler

That will do it.  :)

The major difference between getParentRow and getDependentRowset() is 
that getParentRow() will return a single row whereas 
getDependentRowset() will return a rowset of (in your use case), a 
single row.  But both will work.


-ralph

Joseph Crawford wrote:
Please dis-reguard this question, i am just an idiot and had the table 
name incorrect in my AUX model class.


Thanks,
Joseph Crawford

On Jul 6, 2009, at 1:38 PM, Joseph Crawford wrote:

I did some debugging by also adding the echo $select-__toString() in 
the /Zend/Db/Table/Row/Abstract.php on line 914 which is in the 
findDependentRowset method.


It seems to be outputting the same exact sql query

SELECT `isp_partners`.* FROM `isp_partners`

So for some odd reason it is not getting the dependent 
rowset rather doing the same query and I am not sure why :(


Thanks,
Joseph Crawford


On Jul 6, 2009, at 1:19 PM, Ralph Schindler wrote:



In situations where I have auxiliary and/or errata tables (basically 
a 1-1 relationship), I would look into peering to those rows via the 
findParentRow($parentTable) method rather than finding as a 
DependentRowset.


http://framework.zend.com/manual/en/zend.db.table.relationships.html#zend.db.table.relationships.fetching.parent

It is modeled effectively the same way, but you are using a different 
approach for finding the actual Row.


Let me know if that helps!
-ralph

Now I have it working for the websites and keywords but cannot get 
the isp_partners_aux to work.  The issue seems to be that when I do 
the findDependantRowset it does not get any data from the 
isp_partners_aux table, rather it only contains the data from the 
isp_partners table.  There is only 1 row in each table that will 
match.  The aux table is just an external table that holds data 
about isp_partners such as the username, etc.  Below is my 
controller followed by my model classes and then the output.









Re: [fw-general] Zend_DB_Table: delete() won't delete any row in dependent tables

2009-06-30 Thread Andrew Ballard
On Tue, Jun 30, 2009 at 12:18 AM, Thomas D.whist...@googlemail.com wrote:
 Hi,

 I have two tables, drivers and cars.
 Each driver in drivers has his cars in cars.

 When I delete a driver, his cars should also be deleted in cars.

 I defined two classes:

 class Drivers extends Zend_Db_Table_Abstract
 {
    [...]
    protected $_dependentTables = array(
        'Cars'
    );
 }

 class Cars extends Zend_Db_Table_Abstract
 {
    [...]
    protected $_referenceMap = array(
        'Pages' = array(
            'columns'       = array('driver_id'),
            'refTableClass' = 'Drivers',
            'refColumns'    = 'id',
            'onDelete'      = self::CASCADE
        )
    );
 }

 When I run

 $myTable = new Drivers();
 $driversRowset = $myTable -find(1278);
 $driver = $driversRowset-current();

 $driver-delete();

 The row with id 1278 in my drivers table will be deleted and also all rows
 in cars, where driver_id = 1278. Everything is working as expected.

 Now I want to add a method to my drivers Zend_Db_Table class, which will
 delete a driver and do something else:

 class Drivers extends Zend_Db_Table_Abstract
 {
    [...]
    public function doSth($id)
    {
        $where = $this-_db-quoteInto('id = ?', $id, Zend_Db::INT_TYPE);
        $this-delete($where);

        // do my other stuff
        [...]
    }
 }

 My problem is, that when I call $driverTable-doSth(1278), the row in the
 driver's table will be deleted, but it won't delete any rows in cars.

 Did I miss something?


 --
 Regards,
 Thomas




Is referential integrity not an option?

Andrew


RE: [fw-general] Zend_DB_Table: delete() won't delete any row in dependent tables

2009-06-30 Thread Thomas D.
Hi,

thank you for your reply.

Andrew Ballard wrote:
 Is referential integrity not an option?

No, the tables I am working with are part of a MyISAM database of an existing, 
not fully Zend_Framework based application (I am working on the first 
Zend_Framework based module).

Converting the whole table to InnoDB isn't currently an option.


-- 
Regards,
Thomas




Re: [fw-general] Zend_DB_Table: delete() won't delete any row in dependent tables

2009-06-30 Thread Carlton Gibson
On Tue, Jun 30, 2009 at 12:18 AM, Thomas D.whist...@googlemail.com  
wrote:

Hi,

I have two tables, drivers and cars.
Each driver in drivers has his cars in cars.

When I delete a driver, his cars should also be deleted in cars.

I defined two classes:

class Drivers extends Zend_Db_Table_Abstract
{
   [...]
   protected $_dependentTables = array(
   'Cars'
   );
}

class Cars extends Zend_Db_Table_Abstract
{
   [...]
   protected $_referenceMap = array(
   'Pages' = array(
   'columns'   = array('driver_id'),
   'refTableClass' = 'Drivers',
   'refColumns'= 'id',
   'onDelete'  = self::CASCADE
   )
   );
}

When I run

$myTable = new Drivers();
$driversRowset = $myTable -find(1278);
$driver = $driversRowset-current();

$driver-delete();

The row with id 1278 in my drivers table will be deleted and also  
all rows

in cars, where driver_id = 1278. Everything is working as expected.

Now I want to add a method to my drivers Zend_Db_Table class, which  
will

delete a driver and do something else:

class Drivers extends Zend_Db_Table_Abstract
{
   [...]
   public function doSth($id)
   {
   $where = $this-_db-quoteInto('id = ?', $id,  
Zend_Db::INT_TYPE);

   $this-delete($where);

   // do my other stuff
   [...]
   }
}

My problem is, that when I call $driverTable-doSth(1278), the row  
in the

driver's table will be deleted, but it won't delete any rows in cars.

Did I miss something?



Yes. The cascading write options ONLY work via the Row object.

In your method doSth you are using the table's delete() method, which  
does not enforce the cascade specified in the $_referenceMap array.


In the example previously you are using the row object's delete().  
This does enforce the cascade.


If you change your doSth() method to use fetchRow() and then call  
delete on that all should work as you intend.


I hope this helps. I have been caught out by this one myself and  
(still) am not sure WHY the table's delete() method doesn't behave as  
you expected.


Regards,
Carlton


Re: [fw-general] Zend_DB_Table: delete() won't delete any row in dependent tables

2009-06-30 Thread Andrew Ballard
On Tue, Jun 30, 2009 at 12:18 AM, Thomas D.whist...@googlemail.com wrote:
 Hi,

 I have two tables, drivers and cars.
 Each driver in drivers has his cars in cars.

 When I delete a driver, his cars should also be deleted in cars.

 I defined two classes:

 class Drivers extends Zend_Db_Table_Abstract
 {
    [...]
    protected $_dependentTables = array(
        'Cars'
    );
 }

 class Cars extends Zend_Db_Table_Abstract
 {
    [...]
    protected $_referenceMap = array(
        'Pages' = array(
            'columns'       = array('driver_id'),
            'refTableClass' = 'Drivers',
            'refColumns'    = 'id',
            'onDelete'      = self::CASCADE
        )
    );
 }

 When I run

 $myTable = new Drivers();
 $driversRowset = $myTable -find(1278);
 $driver = $driversRowset-current();

 $driver-delete();

 The row with id 1278 in my drivers table will be deleted and also all rows
 in cars, where driver_id = 1278. Everything is working as expected.

 Now I want to add a method to my drivers Zend_Db_Table class, which will
 delete a driver and do something else:

 class Drivers extends Zend_Db_Table_Abstract
 {
    [...]
    public function doSth($id)
    {
        $where = $this-_db-quoteInto('id = ?', $id, Zend_Db::INT_TYPE);
        $this-delete($where);

        // do my other stuff
        [...]
    }
 }

 My problem is, that when I call $driverTable-doSth(1278), the row in the
 driver's table will be deleted, but it won't delete any rows in cars.

 Did I miss something?


 --
 Regards,
 Thomas




You are changing the syntax between the two examples. In the first,
you are calling finding a specific row and
Zend_Db_Table_Row_Abstract::delete() on that row, which is what is
shown in the documentation. This function scans the dependent tables
and deletes all dependent rows.

In the second, you are calling the Zend_Db_Table_Abstract::delete()
method, which simply calls delete() on the database adapter.

It looks like you just need to change your doSth() method to this:

class Drivers extends Zend_Db_Table_Abstract
{
   [...]
   public function doSth($id)
   {
   $driversRowset = $this-find($id);
   $driver = $driversRowset-current();

   $driver-delete();

   // do my other stuff
   [...]
   }
}

Andrew


RE: [fw-general] Zend_DB_Table: delete() won't delete any row in dependent tables

2009-06-30 Thread Thomas D.
Hi,

Andrew Ballard wrote:
 You are changing the syntax between the two examples. In the first,
 you are calling finding a specific row and
 Zend_Db_Table_Row_Abstract::delete() on that row, which is what is
 shown in the documentation. This function scans the dependent tables
 and deletes all dependent rows.
 
 In the second, you are calling the Zend_Db_Table_Abstract::delete()
 method, which simply calls delete() on the database adapter.
 
 It looks like you just need to change your doSth() method to this:
 
 class Drivers extends Zend_Db_Table_Abstract
 {
[...]
public function doSth($id)
{
$driversRowset = $this-find($id);
$driver = $driversRowset-current();
 
$driver-delete();
 
// do my other stuff
[...]
}
 }

You are right. The delete() method, which will delete rows in dependent tables 
is the delete() method of the Zend_Db_Table_Row, but I was using the delete() 
method of Zend_Db_Table.

Your solution is working fine.

Thank you Andrew.


-- 
Regards,
Thomas




Re: [fw-general] Zend_DB_Table: delete() won't delete any row in dependent tables

2009-06-30 Thread Ben Scholzen 'DASPRiD'
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

You should probably take a look at Foreign Keys and Cascading in your
database's manual.
...
:  ___   _   ___ ___ ___ _ ___:
: |   \ /_\ / __| _ \ _ (_)   \   :
: | |) / _ \\__ \  _/   / | |) |  :
: |___/_/:\_\___/_| |_|_\_|___/   :
:::
: Web: http://www.dasprids.de :
: E-mail : m...@dasprids.de   :
: Jabber : jab...@dasprids.de :
: ICQ: 105677955  :
:::


Thomas D. schrieb:
 Hi,
 
 I have two tables, drivers and cars.
 Each driver in drivers has his cars in cars.
 
 When I delete a driver, his cars should also be deleted in cars.
 
 I defined two classes:
 
 class Drivers extends Zend_Db_Table_Abstract
 {
 [...]
 protected $_dependentTables = array(
 'Cars'
 );
 }
 
 class Cars extends Zend_Db_Table_Abstract
 {
 [...]
 protected $_referenceMap = array(
 'Pages' = array(
 'columns'   = array('driver_id'),
 'refTableClass' = 'Drivers',
 'refColumns'= 'id',
 'onDelete'  = self::CASCADE
 )
 );
 }
 
 When I run
 
 $myTable = new Drivers();
 $driversRowset = $myTable -find(1278);
 $driver = $driversRowset-current();
 
 $driver-delete();
 
 The row with id 1278 in my drivers table will be deleted and also all rows
 in cars, where driver_id = 1278. Everything is working as expected.
 
 Now I want to add a method to my drivers Zend_Db_Table class, which will
 delete a driver and do something else:
 
 class Drivers extends Zend_Db_Table_Abstract
 {
 [...]
 public function doSth($id)
 {
 $where = $this-_db-quoteInto('id = ?', $id, Zend_Db::INT_TYPE);
 $this-delete($where);
 
 // do my other stuff
 [...]
 }
 }
 
 My problem is, that when I call $driverTable-doSth(1278), the row in the
 driver's table will be deleted, but it won't delete any rows in cars.
 
 Did I miss something?
 
 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpKI5cACgkQ0HfT5Ws789B2ogCgiElFfBypyBWKPD3l5v4dqa1k
wkkAoIe7o8TUAhNCBFXRdgrV1T4ZUmUN
=mSbg
-END PGP SIGNATURE-


RE: [fw-general] Zend_DB_Table: delete() won't delete any row in dependent tables

2009-06-30 Thread Thomas D.
Hi,

Ben Scholzen 'DASPRiD' wrote:
 You should probably take a look at Foreign Keys and Cascading in your
 database's manual.

As I have written in a reply for Andrew, the database I am working with uses
the MyISAM engine, which don't support foreign keys.

Converting the engine to InnoDB is currently not an option. This would
require further testing of other - old - modules.


-- 
Regards,
Thomas




RE: [fw-general] Zend_DB_Table: delete() won't delete any row in dependent tables

2009-06-30 Thread Thomas D.
Hi,

Carlton Gibson wrote:
  My problem is, that when I call $driverTable-doSth(1278), the row
  in the driver's table will be deleted, but it won't delete any rows
  in cars.
  
  Did I miss something?
 
 Yes. The cascading write options ONLY work via the Row object.

Thank you, too. That was the problem.


-- 
Regards,
Thomas




Re: [fw-general] Zend_Db_Table

2009-05-08 Thread holografix .
Hi

Missed that one. Didn't know about Zend_Db_Table deprecation.

Thank you very much.

Cheers
holo

2009/5/7 Matthew Weier O'Phinney matt...@zend.com

 -- holografix . hologra...@gmail.com wrote
 (on Thursday, 07 May 2009, 05:07 PM +0100):
   Hi
 
  What's the difference between this ?
 
  $config = $this-config-db;
  $db= Zend_Db::factory($config);
  ..
  ..
   Zend_Db_Table::setDefaultAdapter($db);
  vs
 
  Zend_Db_Table_Abstract::setDefaultAdapter($db);

 They're the same, basically. However, the Zend_Db_Table was deprecated
 starting in 0.9, so the latter, Zend_Db_Table_Abstract, is the more
 appropriate approach.

 --
 Matthew Weier O'Phinney
 Project Lead| matt...@zend.com
 Zend Framework  | http://framework.zend.com/



Re: [fw-general] Zend_Db_Table

2009-05-08 Thread Ralph Schindler
This is also subject to change.  Currently there is an issue in the 
issue tracker that I am taking on currently:


http://framework.zend.com/issues/browse/ZF-3486

Effectively, the new code will make it possible to use Zend_Db_Table in 
a concrete way.. this is opposed to the current methodology where one 
must extend the abstract classes.


-ralph

holografix . wrote:

Hi
 
Missed that one. Didn't know about Zend_Db_Table deprecation.
 
Thank you very much.
 
Cheers

holo

2009/5/7 Matthew Weier O'Phinney matt...@zend.com 
mailto:matt...@zend.com


-- holografix . hologra...@gmail.com mailto:hologra...@gmail.com
wrote
(on Thursday, 07 May 2009, 05:07 PM +0100):
  Hi
 
  What's the difference between this ?
 
  $config = $this-config-db;
  $db= Zend_Db::factory($config);
  ..
  ..
   Zend_Db_Table::setDefaultAdapter($db);
  vs
 
  Zend_Db_Table_Abstract::setDefaultAdapter($db);

They're the same, basically. However, the Zend_Db_Table was deprecated
starting in 0.9, so the latter, Zend_Db_Table_Abstract, is the more
appropriate approach.

--
Matthew Weier O'Phinney
Project Lead| matt...@zend.com mailto:matt...@zend.com
Zend Framework  | http://framework.zend.com/




Re: [fw-general] Zend_Db_Table

2009-05-07 Thread Matthew Weier O'Phinney
-- holografix . hologra...@gmail.com wrote
(on Thursday, 07 May 2009, 05:07 PM +0100):
 Hi
  
 What's the difference between this ?
  
 $config = $this-config-db;
 $db= Zend_Db::factory($config);
 ..
 ..
  Zend_Db_Table::setDefaultAdapter($db);
 vs
  
 Zend_Db_Table_Abstract::setDefaultAdapter($db);

They're the same, basically. However, the Zend_Db_Table was deprecated
starting in 0.9, so the latter, Zend_Db_Table_Abstract, is the more
appropriate approach.

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/


Re: [fw-general] Zend_Db_Table How best to associate an object with a db table?

2009-04-27 Thread Sudheer Satyanarayana

J DeBord wrote:
This may be partially a general oop question, but I hope someone can 
give me some advice.


If you want to build a User object, what is the best way to store it's 
attributes? Would a user object extend a Zend_Db_Table? Would you code 
a User class and have it interact with a UserTable extends 
Zend_Db_Table class? Can anyone provide a general example of code 
please? Or any advice? Books to read, sites to visit, etc...



Personally, I prefer not to extend Zend_Db_Table for models.

Matthew has written about it previously. 
http://weierophinney.net/matthew/archives/202-Model-Infrastructure.html 
You should follow Matthew's blog for tutorials, news and insight about 
Zend Framework. There's also a free book available on ZF - 
http://www.survivethedeepend.com/



--

With warm regards,
Sudheer. S
Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, 
Personal: http://sudheer.net



Re: [fw-general] Zend_Db_Table How best to associate an object with a db table?

2009-04-27 Thread Karol Grecki

Jason,

I suggest you use Zend_Db_Table to retrieve corresponding row and store it
as a member variable (Zend_Db_Table_Row). You can expose its properties
using __get/set for ease of use. Extending Zend_Db_Table would be a bad
idea.

Karol


J DeBord wrote:
 
 This may be partially a general oop question, but I hope someone can give
 me
 some advice.
 
 If you want to build a User object, what is the best way to store it's
 attributes? Would a user object extend a Zend_Db_Table? Would you code a
 User class and have it interact with a UserTable extends Zend_Db_Table
 class? Can anyone provide a general example of code please? Or any advice?
 Books to read, sites to visit, etc...
 
 Thanks a lot.
 
 Jason DEBORD
 Limoges, France
 
 http://www.jasondebord.net/
 
 

-- 
View this message in context: 
http://www.nabble.com/Zend_Db_Table-How-best-to-associate-an-object-with-a-db-table--tp23245110p23251895.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Db_Table How best to associate an object with a db table?

2009-04-27 Thread J DeBord
Karol, I thought about using Zend_Db_Table_Row somehow. Would the Row object
become a variable of the user class? Then if the User's attributes change,
you would actually be changing the attributes of the Row object? This sounds
great, I just don't have enough experience to know if this is the best way
to go about it.

Thanks a lot.

J

On Mon, Apr 27, 2009 at 10:13 AM, Karol Grecki kgre...@gmail.com wrote:


 Jason,

 I suggest you use Zend_Db_Table to retrieve corresponding row and store it
 as a member variable (Zend_Db_Table_Row). You can expose its properties
 using __get/set for ease of use. Extending Zend_Db_Table would be a bad
 idea.

 Karol


 J DeBord wrote:
 
  This may be partially a general oop question, but I hope someone can give
  me
  some advice.
 
  If you want to build a User object, what is the best way to store it's
  attributes? Would a user object extend a Zend_Db_Table? Would you code a
  User class and have it interact with a UserTable extends Zend_Db_Table
  class? Can anyone provide a general example of code please? Or any
 advice?
  Books to read, sites to visit, etc...
 
  Thanks a lot.
 
  Jason DEBORD
  Limoges, France
 
  http://www.jasondebord.net/
 
 

 --
 View this message in context:
 http://www.nabble.com/Zend_Db_Table-How-best-to-associate-an-object-with-a-db-table--tp23245110p23251895.html
 Sent from the Zend Framework mailing list archive at Nabble.com.




Re: [fw-general] Zend_Db_Table How best to associate an object with a db table?

2009-04-27 Thread J DeBord
Thanks Cem,

I am going to look at Zend_Db_Table_* classes for sure. I appreciate the
guidance.

And for everyone, I just read this article of Matthew's
http://weierophinney.net/matthew/archives/202-Model-Infrastructure.html and
it is awesome. Thanks Matthew.

On Mon, Apr 27, 2009 at 12:58 PM, Cem Derin c...@wysiwyg.de wrote:

 Zend_Db_Table (respective any inherited class) represents all users (the
 full table). Zend_Db_Table_Row represents a single user (a single record).

 Thats how I use the Zend_Db_Table_*-Classes (and I extend them massively
 without any problem).

 Cheers,

 Cem

 J DeBord schrieb:

 Karol, I thought about using Zend_Db_Table_Row somehow. Would the Row
 object become a variable of the user class? Then if the User's attributes
 change, you would actually be changing the attributes of the Row object?
 This sounds great, I just don't have enough experience to know if this is
 the best way to go about it.

 Thanks a lot.

 J

 On Mon, Apr 27, 2009 at 10:13 AM, Karol Grecki kgre...@gmail.commailto:
 kgre...@gmail.com wrote:


Jason,

I suggest you use Zend_Db_Table to retrieve corresponding row and
store it
as a member variable (Zend_Db_Table_Row). You can expose its
properties
using __get/set for ease of use. Extending Zend_Db_Table would be
a bad
idea.

Karol


J DeBord wrote:

 This may be partially a general oop question, but I hope someone
can give
 me
 some advice.

 If you want to build a User object, what is the best way to
store it's
 attributes? Would a user object extend a Zend_Db_Table? Would
you code a
 User class and have it interact with a UserTable extends
Zend_Db_Table
 class? Can anyone provide a general example of code please? Or
any advice?
 Books to read, sites to visit, etc...

 Thanks a lot.

 Jason DEBORD
 Limoges, France

 http://www.jasondebord.net/



--
View this message in context:

 http://www.nabble.com/Zend_Db_Table-How-best-to-associate-an-object-with-a-db-table--tp23245110p23251895.html
Sent from the Zend Framework mailing list archive at Nabble.com.






Re: [fw-general] Zend_Db_Table - A class for every table? Overhead?

2008-05-20 Thread James Dempster
wow that seems slow, try looking for any
sleep(rand(3,4));

only j/k lol ;-)

--
/James

On Mon, May 19, 2008 at 9:54 PM, Philip G [EMAIL PROTECTED] wrote:


 I'm at a bit of an impasse here.

 I'm trying to understand the reason for having a Zend_Db_Table object for
 every table in the database while balancing the class creation overhead. In
 PHP, creating a class (especially a Zend_Db_Table class) has a fair bit of
 overhead. It's not something that's small either. A quick creation of 7-8
 objects can easily slow the application down by 3-4 seconds. In my
 environment, that's a great deal. Compound that with the fact our database
 is extremely normalized and we're often working with a dozen tables for a
 simple application...is the overhead worth it?

 I like Zend_Db_Table. I like the functionality it gives, but I'm having a
 hard time justifying to myself, and my peers, the noticible performance
 impact it creates.

 It just feels having a class per table has some uncessary overhead. Why not
 a couple/few static classes for basics: insert, update. I often do selects
 across 3-4 tables at a time, and the current Zend_Db_Table implementation
 doesn't seem to make this much easier than just creating my own select
 statement using Zend_Db_Select.

 For some reason, it seems as if I'm missing somethingam I?

 --
 Philip
 [EMAIL PROTECTED]
 http://www.gpcentre.net/


Re: [fw-general] Zend_Db_Table - A class for every table? Overhead?

2008-05-20 Thread Philip G
On Mon, May 19, 2008 at 4:02 PM, Bradley Holt [EMAIL PROTECTED]
wrote:

 Philip,

 On Mon, May 19, 2008 at 4:54 PM, Philip G [EMAIL PROTECTED] wrote:


 I'm at a bit of an impasse here.

 I'm trying to understand the reason for having a Zend_Db_Table object for
 every table in the database while balancing the class creation overhead. In
 PHP, creating a class (especially a Zend_Db_Table class) has a fair bit of
 overhead. It's not something that's small either. A quick creation of 7-8
 objects can easily slow the application down by 3-4 seconds.


 Do you have some data to back that up? I've never heard of object creation
 being anywhere close to that slow in PHP. I would think the time to create
 an object would be negligible compared to the overhead of database access
 itself.



Sure. I'll try to get a little test together. I happen to have experienced
first hand looping over ~8-10 survey answers where initially I created a
new table object for each one.

My program was up to 5-6 seconds to complete. I traced it down to one
section where I was looping over all my survey answers and inserting them
into the table (one row per answer). Initially, I created a new class for
each one. My thought was a new row, a new class -- I did that, but it
slowed down that section by 3 seconds. So I changed my wrapper class to use
a static variable for the table and did an insert() against that. Dropped it
down to under a second execution for that one section.

theories as to the cause:
 - Our DB is Oracle, on a remote host. We have remote connection lag.
 - Every time you create a new DB Table object, Zend_Db pulls a describe.
That describe adds noticeable lag when looping over 8 objects within
seconds.
 - Creating a new class isn't obtimal, but does show natural possible lag
issues.

I was creating a new table object for every row getting inserted; which was
probably a bad idea. However, it does show an example on how creating table
objects can slow down code.

(on and yes, each object was using the same static db connector)

Additionally, object creation overhead is going to be insignificant
 compared to DB access; I've created scripts that create many thousands
 of objects in under a second.


I'm curious on the benchmarks on creating classes. I'm often in battles with
a fellow co-worker about class creation. lol
He's a speed extremist; and I mean extremist. He's all about pulling even
the most minute of milliseconds out for speed (eg: he advocates if/else
instead of ternary). It's hard to get him on board when PHP objects have an
inherited overhead. :(
This above example is an extreme case, but definitely shows the inherent lag
within PHP class creation. It's a bit hard to speak for PHP classes when we
do see this lag issues. He's very, very much against constant class creation
-- hard to argue without real ammo against it.


wow that seems slow, try looking for any
 sleep(rand(3,4));

 only j/k lol ;-)



Ha. I laughed. ;-)


-- 
Philip
[EMAIL PROTECTED]
http://www.gpcentre.net/


Re: [fw-general] Zend_Db_Table - A class for every table? Overhead?

2008-05-20 Thread Luke Richards

Hi Philip,

One suggestion might be to use the Zend_Cache with Zend_Db_Table. Using 
the cache means you won't get the describe request overhead except for 
the first time populating the cache (per table).


http://framework.zend.com/manual/en/zend.db.table.html#zend.db.table.metadata.caching

Hope that helps a little.

Luke

Philip G wrote:
On Mon, May 19, 2008 at 4:02 PM, Bradley Holt 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:


Philip,

On Mon, May 19, 2008 at 4:54 PM, Philip G [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:


I'm at a bit of an impasse here.

I'm trying to understand the reason for having a Zend_Db_Table
object for every table in the database while balancing the
class creation overhead. In PHP, creating a class (especially
a Zend_Db_Table class) has a fair bit of overhead. It's not
something that's small either. A quick creation of 7-8 objects
can easily slow the application down by 3-4 seconds. 



Do you have some data to back that up? I've never heard of object
creation being anywhere close to that slow in PHP. I would think
the time to create an object would be negligible compared to the
overhead of database access itself.
 



Sure. I'll try to get a little test together. I happen to have 
experienced first hand looping over ~8-10 survey answers where 
initially I created a new table object for each one.


My program was up to 5-6 seconds to complete. I traced it down to one 
section where I was looping over all my survey answers and inserting 
them into the table (one row per answer). Initially, I created a new 
class for each one. My thought was a new row, a new class -- I did 
that, but it slowed down that section by 3 seconds. So I changed my 
wrapper class to use a static variable for the table and did an 
insert() against that. Dropped it down to under a second execution for 
that one section.


theories as to the cause:
 - Our DB is Oracle, on a remote host. We have remote connection lag.
 - Every time you create a new DB Table object, Zend_Db pulls a 
describe. That describe adds noticeable lag when looping over 8 
objects within seconds.
 - Creating a new class isn't obtimal, but does show natural possible 
lag issues.


I was creating a new table object for every row getting inserted; 
which was probably a bad idea. However, it does show an example on how 
creating table objects can slow down code.


(on and yes, each object was using the same static db connector)

Additionally, object creation overhead is going to be insignificant
compared to DB access; I've created scripts that create many thousands
of objects in under a second.


I'm curious on the benchmarks on creating classes. I'm often in 
battles with a fellow co-worker about class creation. lol
He's a speed extremist; and I mean extremist. He's all about pulling 
even the most minute of milliseconds out for speed (eg: he advocates 
if/else instead of ternary). It's hard to get him on board when PHP 
objects have an inherited overhead. :(
This above example is an extreme case, but definitely shows the 
inherent lag within PHP class creation. It's a bit hard to speak for 
PHP classes when we do see this lag issues. He's very, very much 
against constant class creation -- hard to argue without real ammo 
against it.



wow that seems slow, try looking for any
sleep(rand(3,4));

only j/k lol ;-)



Ha. I laughed. ;-)


--
Philip
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
http://www.gpcentre.net/ 


Re: [fw-general] Zend_Db_Table - A class for every table? Overhead?

2008-05-20 Thread Bradley Holt
Philip,

On Tue, May 20, 2008 at 8:48 AM, Philip G [EMAIL PROTECTED] wrote:

 On Mon, May 19, 2008 at 4:02 PM, Bradley Holt [EMAIL PROTECTED]
 wrote:

 Philip,

 On Mon, May 19, 2008 at 4:54 PM, Philip G [EMAIL PROTECTED] wrote:


 I'm at a bit of an impasse here.

 I'm trying to understand the reason for having a Zend_Db_Table object for
 every table in the database while balancing the class creation overhead. In
 PHP, creating a class (especially a Zend_Db_Table class) has a fair bit of
 overhead. It's not something that's small either. A quick creation of 7-8
 objects can easily slow the application down by 3-4 seconds.


 Do you have some data to back that up? I've never heard of object creation
 being anywhere close to that slow in PHP. I would think the time to create
 an object would be negligible compared to the overhead of database access
 itself.



 Sure. I'll try to get a little test together. I happen to have experienced
 first hand looping over ~8-10 survey answers where initially I created a
 new table object for each one.

 My program was up to 5-6 seconds to complete. I traced it down to one
 section where I was looping over all my survey answers and inserting them
 into the table (one row per answer). Initially, I created a new class for
 each one. My thought was a new row, a new class -- I did that, but it
 slowed down that section by 3 seconds. So I changed my wrapper class to use
 a static variable for the table and did an insert() against that. Dropped it
 down to under a second execution for that one section.


Do you mean a new row, a new class or a new row, a new object? I can't
imagine you mean the first, but just asking ;-)

Also, are you instantiating the Zend_Db_Table objects on each iteration of
the loop? I'm pretty sure (someone correct me if I'm wrong on this) that you
only need one instance of each Zend_Db_Table class so I'd make sure you're
initializing the table objects you'll need before you enter the loop.




 theories as to the cause:
  - Our DB is Oracle, on a remote host. We have remote connection lag.
  - Every time you create a new DB Table object, Zend_Db pulls a describe.
 That describe adds noticeable lag when looping over 8 objects within
 seconds.
  - Creating a new class isn't obtimal, but does show natural possible lag
 issues.

 I was creating a new table object for every row getting inserted; which was
 probably a bad idea. However, it does show an example on how creating table
 objects can slow down code.

 (on and yes, each object was using the same static db connector)

 Additionally, object creation overhead is going to be insignificant
 compared to DB access; I've created scripts that create many thousands
 of objects in under a second.


 I'm curious on the benchmarks on creating classes. I'm often in battles
 with a fellow co-worker about class creation. lol
 He's a speed extremist; and I mean extremist. He's all about pulling even
 the most minute of milliseconds out for speed (eg: he advocates if/else
 instead of ternary). It's hard to get him on board when PHP objects have an
 inherited overhead. :(
 This above example is an extreme case, but definitely shows the inherent
 lag within PHP class creation. It's a bit hard to speak for PHP classes when
 we do see this lag issues. He's very, very much against constant class
 creation -- hard to argue without real ammo against it.


You might point out to him that premature optimization is the root of all
evil http://c2.com/cgi/wiki?PrematureOptimization :-)

Seriously, though, is he optimizing after you've got a good design or is he
trying to build optimization into the original design? I usually find it
best to have a good design first, and then optimize later. A good design can
be refactored to be more optimized but a bad design can be a real pain to
maintain, no matter how fast it is. Usually your assumptions about what
parts of your code will be slow are wrong so not focusing on good design
first can actually make it so you end up with less optimized code because it
becomes so difficult to refactor.





 wow that seems slow, try looking for any
 sleep(rand(3,4));

 only j/k lol ;-)



 Ha. I laughed. ;-)



 --
 Philip
 [EMAIL PROTECTED]
 http://www.gpcentre.net/




-- 
Bradley Holt
[EMAIL PROTECTED]


Re: [fw-general] Zend_Db_Table - A class for every table? Overhead?

2008-05-20 Thread Philip G
On Tue, May 20, 2008 at 8:55 AM, Bradley Holt [EMAIL PROTECTED]
wrote:

 Philip,

 On Tue, May 20, 2008 at 8:48 AM, Philip G [EMAIL PROTECTED] wrote:

 Sure. I'll try to get a little test together. I happen to have experienced
 first hand looping over ~8-10 survey answers where initially I created a
 new table object for each one.

 My program was up to 5-6 seconds to complete. I traced it down to one
 section where I was looping over all my survey answers and inserting them
 into the table (one row per answer). Initially, I created a new class for
 each one. My thought was a new row, a new class -- I did that, but it
 slowed down that section by 3 seconds. So I changed my wrapper class to use
 a static variable for the table and did an insert() against that. Dropped it
 down to under a second execution for that one section.


 Do you mean a new row, a new class or a new row, a new object? I can't
 imagine you mean the first, but just asking ;-)

 Also, are you instantiating the Zend_Db_Table objects on each iteration of
 the loop? I'm pretty sure (someone correct me if I'm wrong on this) that you
 only need one instance of each Zend_Db_Table class so I'd make sure you're
 initializing the table objects you'll need before you enter the loop.



I did indeed mean a new row, a new object. ;)
For some reason, I initially thought when you did an insert() that class
automatically because the row you just inserted. Dunno why I thought that --
so I failed to code it exactly optimal for this situation. The reason it
happened in a loop is because I was actually looping through a
$survey-addAnswers(); and within that answers method is where I interacted
with the table and initially, did a $table = new Table() each time. Now it's
if ( empty(self::$table) ) { self::$table = new Table(); }







 I'm curious on the benchmarks on creating classes. I'm often in battles
 with a fellow co-worker about class creation. lol
 He's a speed extremist; and I mean extremist. He's all about pulling even
 the most minute of milliseconds out for speed (eg: he advocates if/else
 instead of ternary). It's hard to get him on board when PHP objects have an
 inherited overhead. :(
 This above example is an extreme case, but definitely shows the inherent
 lag within PHP class creation. It's a bit hard to speak for PHP classes when
 we do see this lag issues. He's very, very much against constant class
 creation -- hard to argue without real ammo against it.


 You might point out to him that premature optimization is the root of all
 evil http://c2.com/cgi/wiki?PrematureOptimization :-)

 Seriously, though, is he optimizing after you've got a good design or is he
 trying to build optimization into the original design? I usually find it
 best to have a good design first, and then optimize later. A good design can
 be refactored to be more optimized but a bad design can be a real pain to
 maintain, no matter how fast it is. Usually your assumptions about what
 parts of your code will be slow are wrong so not focusing on good design
 first can actually make it so you end up with less optimized code because it
 becomes so difficult to refactor.



He's an interesting character. It believes in designing around
optimizations. You should design your code to the 'up most' optimized
possibility for what you're doing. I'm quite the opposite thinker, too. Like
you, I believe in designing the code and then optimizing.

You can imagine the discussions he and I always have. We're always bickering
with each other in determining the best path for something. It's so bad,
we've became the department rivals. lol


-- 
Philip
[EMAIL PROTECTED]
http://www.gpcentre.net/


Re: [fw-general] Zend_Db_Table - A class for every table? Overhead?

2008-05-19 Thread Bradley Holt
Philip,

On Mon, May 19, 2008 at 4:54 PM, Philip G [EMAIL PROTECTED] wrote:


 I'm at a bit of an impasse here.

 I'm trying to understand the reason for having a Zend_Db_Table object for
 every table in the database while balancing the class creation overhead. In
 PHP, creating a class (especially a Zend_Db_Table class) has a fair bit of
 overhead. It's not something that's small either. A quick creation of 7-8
 objects can easily slow the application down by 3-4 seconds.


Do you have some data to back that up? I've never heard of object creation
being anywhere close to that slow in PHP. I would think the time to create
an object would be negligible compared to the overhead of database access
itself.


 In my environment, that's a great deal. Compound that with the fact our
 database is extremely normalized and we're often working with a dozen tables
 for a simple application...is the overhead worth it?

 I like Zend_Db_Table. I like the functionality it gives, but I'm having a
 hard time justifying to myself, and my peers, the noticible performance
 impact it creates.

 It just feels having a class per table has some uncessary overhead. Why not
 a couple/few static classes for basics: insert, update. I often do selects
 across 3-4 tables at a time, and the current Zend_Db_Table implementation
 doesn't seem to make this much easier than just creating my own select
 statement using Zend_Db_Select.

 For some reason, it seems as if I'm missing somethingam I?

 --
 Philip
 [EMAIL PROTECTED]
 http://www.gpcentre.net/




-- 
Bradley Holt
[EMAIL PROTECTED]


Re: [fw-general] Zend_Db_Table - A class for every table? Overhead?

2008-05-19 Thread Matthew Weier O'Phinney
-- Philip G [EMAIL PROTECTED] wrote
(on Monday, 19 May 2008, 03:54 PM -0500):
 I'm at a bit of an impasse here.
 
 I'm trying to understand the reason for having a Zend_Db_Table object
 for every table in the database while balancing the class creation
 overhead. In PHP, creating a class (especially a Zend_Db_Table class)
 has a fair bit of overhead.  It's not something that's small either. A
 quick creation of 7-8 objects can easily slow the application down by
 3-4 seconds. 

Can you give some benchmarks and code backing up that statement? Don't
mean to be combative, but I've _never_ experienced such a slowdown when
using Zend_Db_Table, and I've used it heavily on a few projects.
Additionally, object creation overhead is going to be insignificant
compared to DB access; I've created scripts that create many thousands
of objects in under a second.

If you're using the same DB adapter for all tables, you'll be re-using
the same connection, so once it is established for one table object,
it's established for all -- so this also seems a straw man argument.

 In my environment, that's a great deal. Compound that with the fact
 our database is extremely normalized and we're often working with a
 dozen tables for a simple application...is the overhead worth it?
 
 I like Zend_Db_Table. I like the functionality it gives, but I'm
 having a hard time justifying to myself, and my peers, the noticible
 performance impact it creates.
 
 It just feels having a class per table has some uncessary overhead.
 Why not a couple/few static classes for basics: insert, update. I
 often do selects across 3-4 tables at a time, and the current
 Zend_Db_Table implementation doesn't seem to make this much easier
 than just creating my own select statement using Zend_Db_Select.
 
 For some reason, it seems as if I'm missing somethingam I?

There are multiple reasons for having a class per table:

  * Type hinting. It becomes easy to pass table objects around and
branch based on object type.

  * Business logic. Each table can have its own accessors and custom
logic via its own class.

  * Overriding operations. You can implement your own custom hooks for
pre/post insert/update/delete operations per table.

The new logic in Zend_Db_Table for doing JOINs is actually quite nice,
and combines the advantages of Zend_Db_Select with returning
Zend_Db_Table_Rowsets -- which offers the advantage of having a unified
return type for all operations on that table.

Provide some sample code, benchmarks, and info on the environment you're
using (OS, PHP version, etc.) -- it may be possible that you're not
doing things in an optimal fashion, or that something in your
environment is causing the issues you're seeing.

-- 
Matthew Weier O'Phinney
Software Architect   | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/


Re: [fw-general] Zend_Db_Table: Problem with Relatationships

2008-03-06 Thread Bill Karwin


Jan Pieper wrote:
 
 $article-findDependentRowset('Author');
 
 But the result is an Exception :(
 
 Zend_Db_Table_Exception: No reference from table Author to table Article
 

In you example, a foreign key in Article references a primary key in Author.

So Author is the parent, Article is the dependent.  You are querying the
reverse relationship, which does not exist in this example.

Use this:

  $article-findParentRow('Author');

Regards,
Bill Karwin
-- 
View this message in context: 
http://www.nabble.com/Zend_Db_Table%3A-Problem-with-Relatationships-tp15882889s16154p15883753.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Db_Table: Problem with Relatationships

2008-03-06 Thread Jan Pieper

Yeah, this works fine :-)

-- Jan



Jan Pieper wrote:

$article-findDependentRowset('Author');

But the result is an Exception :(

Zend_Db_Table_Exception: No reference from table Author to table Article



In you example, a foreign key in Article references a primary key in Author.

So Author is the parent, Article is the dependent.  You are querying the
reverse relationship, which does not exist in this example.

Use this:

  $article-findParentRow('Author');

Regards,
Bill Karwin




Re: [fw-general] Zend_Db_Table I have problems reading columns' alliases

2008-03-01 Thread Tobias Gies

Hey Marek,

You should have read on.
What you want can be done using the following code:

$select-from($ct, array('max_id' = 'MAX(place_id)'))
// et cetera

Best regards,
Tobias

--  
Sent from my iPhone


Am 01.03.2008 um 19:15 schrieb Marek Wawro [EMAIL PROTECTED]:


Hi,
I am having problems to call MAX function in mysql using  
zend_db_table_abstract


Writing that code I based on: http://framework.zend.com/manual/en/zend.db.table.html 
 example 10.95


here is code snipet where  $ct extands Zend_Db_Table_Abstract

$select = $ct-select();
$select-from($ct, 'MAX(place_id) as max_id')-where('shop_id = ?',  
0)-group('shop_id');

$max = $ct-fetchRow($select);

When i am trying to read $max-max_id i am getting exception that  
this column is not existing




Thank you for help

ps:
Here is var_dump of $max variable

object(Zend_Db_Table_Row)#47 (8) {
  [_data:protected]=
  array(1) {
[max_id]=
int(4)
  }
  [_cleanData:protected]=
  array(1) {
[max_id]=
int(4)
  }
  [_modifiedFields:protected]=
  array(0) {
  }
  [_table:protected]=
  object(Content)#126 (13) {
[_name:protected]=
string(7) content
[_primary:protected]=
array(1) {
  [1]=
  string(10) content_id
}
[_db:protected]=
object(Zend_Db_Adapter_Mysqli)#37 (9) {
  [_numericDataTypes:protected]=
  array(16) {
[0]=
int(0)
[1]=
int(1)
[2]=
int(2)
[INT]=
int(0)
[INTEGER]=
int(0)
[MEDIUMINT]=
int(0)
[SMALLINT]=
int(0)
[TINYINT]=
int(0)
[BIGINT]=
int(1)
[SERIAL]=
int(1)
[DEC]=
int(2)
[DECIMAL]=
int(2)
[DOUBLE]=
int(2)
[DOUBLE PRECISION]=
int(2)
[FIXED]=
int(2)
[FLOAT]=
int(2)
  }
  [_stmt:protected]=
  object(Zend_Db_Statement_Mysqli)#82 (12) {
[_stmt:protected]=
object(


Re: [fw-general] Zend_Db_Table I have problems reading columns' alliases

2008-03-01 Thread James Dempster
Not 100% sure but I think you'll need

$select-from($ct, array('max_id' = new Zend_Db_Expr('MAX(place_id)') ))
// et cetera


On Sat, Mar 1, 2008 at 6:27 PM, Tobias Gies [EMAIL PROTECTED]
wrote:

 Hey Marek,

 You should have read on.
 What you want can be done using the following code:

 $select-from($ct, array('max_id' = 'MAX(place_id)'))
 // et cetera

 Best regards,
 Tobias

 --
 Sent from my iPhone

 Am 01.03.2008 um 19:15 schrieb Marek Wawro [EMAIL PROTECTED]:

 Hi,I am having problems to call MAX function in mysql using
 zend_db_table_abstract

 Writing that code I based on: 
 http://framework.zend.com/manual/en/zend.db.table.html
 http://framework.zend.com/manual/en/zend.db.table.html example 10.95

 here is code snipet where  $ct extands Zend_Db_Table_Abstract
 $select = $ct-select();
 $select-from($ct, 'MAX(place_id) as max_id')-where('shop_id = ?', 0
 )-group('shop_id');
 $max = $ct-fetchRow($select);

 When i am trying to read $max-max_id i am getting exception that this
 column is not existing



 Thank you for help

 ps:
 Here is var_dump of $max variable

 object(Zend_Db_Table_Row)#47 (8) {
   [_data:protected]=
   array(1) {
 [max_id]=
 int(4)
   }
   [_cleanData:protected]=
   array(1) {
 [max_id]=
 int(4)
   }
   [_modifiedFields:protected]=
   array(0) {
   }
   [_table:protected]=
   object(Content)#126 (13) {
 [_name:protected]=
 string(7) content
 [_primary:protected]=
 array(1) {
   [1]=
   string(10) content_id
 }
 [_db:protected]=
 object(Zend_Db_Adapter_Mysqli)#37 (9) {
   [_numericDataTypes:protected]=
   array(16) {
 [0]=
 int(0)
 [1]=
 int(1)
 [2]=
 int(2)
 [INT]=
 int(0)
 [INTEGER]=
 int(0)
 [MEDIUMINT]=
 int(0)
 [SMALLINT]=
 int(0)
 [TINYINT]=
 int(0)
 [BIGINT]=
 int(1)
 [SERIAL]=
 int(1)
 [DEC]=
 int(2)
 [DECIMAL]=
 int(2)
 [DOUBLE]=
 int(2)
 [DOUBLE PRECISION]=
 int(2)
 [FIXED]=
 int(2)
 [FLOAT]=
 int(2)
   }
   [_stmt:protected]=
   object(Zend_Db_Statement_Mysqli)#82 (12) {
 [_stmt:protected]=
 object(




-- 
/James


Re: [fw-general] Zend_Db_Table I have problems reading columns' alliases

2008-03-01 Thread Bill Karwin


JDempster wrote:
 
 Not 100% sure but I think you'll need
 
 $select-from($ct, array('max_id' = new Zend_Db_Expr('MAX(place_id)') ))
 

Actually, neither change is necessary.  Zend_Db_Select recognizes the
pattern of parentheses, and assumes it should be a Zend_Db_Expr.  It also
recognizes the pattern of expr as alias and assumes it should use the
latter word as an alias as if you had given it as an assoc array key.

Regards,
Bill Karwin
-- 
View this message in context: 
http://www.nabble.com/Zend_Db_Table-I-have-problems-reading-columns%27-alliases-tp15779311s16154p15780877.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Db_Table I have problems reading columns' alliases

2008-03-01 Thread James Dempster
:-) clever framework, so happy I use ZF!

On Sat, Mar 1, 2008 at 9:30 PM, Bill Karwin [EMAIL PROTECTED] wrote:



 JDempster wrote:
 
  Not 100% sure but I think you'll need
 
  $select-from($ct, array('max_id' = new Zend_Db_Expr('MAX(place_id)')
 ))
 

 Actually, neither change is necessary.  Zend_Db_Select recognizes the
 pattern of parentheses, and assumes it should be a Zend_Db_Expr.  It also
 recognizes the pattern of expr as alias and assumes it should use the
 latter word as an alias as if you had given it as an assoc array key.

 Regards,
 Bill Karwin
 --
 View this message in context:
 http://www.nabble.com/Zend_Db_Table-I-have-problems-reading-columns%27-alliases-tp15779311s16154p15780877.html
 Sent from the Zend Framework mailing list archive at Nabble.com.




-- 
/James


Re: [fw-general] Zend_DB_TABLE and mysqli permission

2007-10-04 Thread mihu

thanks for reply and it's just my mistake.
The database configuration wasn't correct. My bad ... 

thanks all 


mihu wrote:
 
 Is there some sort of mysqli permission limitation?
 I got a exceptions from Zend_DB_TABLE and I am thinking it might be
 something to do w/ mysqli user permission.
 
 Can someone clear this for me?
 
 thanks, 
 

-- 
View this message in context: 
http://www.nabble.com/Zend_DB_TABLE-and-mysqli-permission-tf4552830s16154.html#a13041803
Sent from the Zend Framework mailing list archive at Nabble.com.



RE: [fw-general] Zend_Db_Table without primary key

2007-10-04 Thread Bill Karwin
 -Original Message-
 From: Yannick Derwa [mailto:[EMAIL PROTECTED] 
 
 how use Zend_Db_Table without primary key in my table?
 Because my table don't require a primary key

Your table must have a primary key constraint, or else you can't use it
with Zend_Db_Table.  If you have no primary key, you can still query the
table using SQL queries with the Adapter methods like query() and
fetchAll().

Note on terminology:
 primary key != autoincrement integer column

Regards,
Bill Karwin


RE: [fw-general] Zend_DB_TABLE and mysqli permission

2007-10-02 Thread Bill Karwin
 -Original Message-
 From: mihu [mailto:[EMAIL PROTECTED] 

 I got a exceptions from Zend_DB_TABLE and I am thinking it 
 might be something to do w/ mysqli user permission.
 
 Can someone clear this for me?

Can you show one of the exceptions?  Have you tried running the same
query from another environment, such as the mysql query tool or
phpmyadmin?  Make sure you try this using the same mysql username that
you use in your ZF app.  Also log into the mysql instance from the host
where you run your ZF apps, because it is possible for the same username
to have different permissions depending on the client host from which
you connect to mysql.

Regards,
Bill Karwin


[fw-general] RE : [fw-general] Zend_DB_TABLE and mysqli permission

2007-10-02 Thread Aissam Bazzaoui
i got an amazing error like this yesterday :p

SQLSTATE[42000]: Syntax error or access violation:
1064 You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version
for the right syntax to use near 'to=1)' at line 10#0
/home/aissam/workspace/fotomod/library/Zend/Db/Statement.php(298):
Zend_Db_Statement_Pdo-_execute(Array) #1

after a bit of debugging i found that they have
nothing 
to do with access violation.

in case your made the same mistake as me, i describe
the problem there:

the instruction causing the exception was : 
 $msg-fetchAll(array(to=?=$id));

the problem was in field named to, that generate a
query like this :
 SELECT ... WHERE (to=1)
things that mysql doesn't like since to is reserved
word 

to resolved  this you must quote identifier :
 $to=$msg-getAdapter()-quoteIdentifier('to');
 $msg-fetchAll(array($to=?=$id));

i don't know if it'll be a good idea if we quote the
identifier automaticly by default on mysql (at least
on Zend_Db_Adapter_Pdo_Mysql). Any way the note appear
clearly on the manuel (RTFM :p)

[
Note

The values and identifiers in the SQL expression are
not quoted for you. If you have values or identifiers
that require quoting, you are responsible for doing
this. Use the quote(), quoteInto(), and
quoteIdentifier() methods of the database adapter. 
]

i hope that this will help :)


--- mihu [EMAIL PROTECTED] a écrit :

 
 Is there some sort of mysqli permission limitation?
 I got a exceptions from Zend_DB_TABLE and I am
 thinking it might be
 something to do w/ mysqli user permission.
 
 Can someone clear this for me?
 
 thanks, 
 -- 
 View this message in context:

http://www.nabble.com/Zend_DB_TABLE-and-mysqli-permission-tf4552830s16154.html#a12992638
 Sent from the Zend Framework mailing list archive at
 Nabble.com.
 
 



RE: [fw-general] Zend_Db_Table $_sequence set to false AND inserting row with no PK value

2007-09-03 Thread Bill Karwin
Right -- you must provide a value if you use a natural key, or else you
will get a database error.  
 
There is no need for Zend_Db to enforce this.  The database enforces it,
preventing the insert and returning an error, which is then thrown as a
Zend_Db_Statement_Exception.
 
Regards,
Bill Karwin




From: Julien Pauli [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 03, 2007 1:47 PM
To: Zend Framework General
Subject: [fw-general] Zend_Db_Table $_sequence set to false AND
inserting row with no PK value


Hi,

In the manual it is written that if you put $_sequence to
boolean false, in your ORM definition ( extending Zend_Db_Table_Abstract
), then you'll be forced to provide values for PKs while inserting a new
row. 

However, this feature does not seem to be present actually ..?
inserting blank value still proxies to Adapter and creates a DB
error ( caused by a NULL to be inserted on a PK col ) that give
logically a Zend_Db_Statement_Exception 

Thx for response.

Julien.




Re: [fw-general] Zend_DB_Table emulate this query

2007-08-23 Thread Ian Warner

Ignore this:

try {

// Lookup in the database Players that fit this word
$table = new sites_lovefootball_models_Players();
$where = 'MATCH (fname,sname) AGAINST (Ashton)';
$row   = $table-fetchRow($where);

echo 'pre'; print_r($row); echo '/pre';

} catch (Exception $e) {
echo 'Failed: ' . $e-getMessage();
}

Ian Warner wrote:

Hi

Is it possible to emulate this in Zend_DB_Table:

SELECT A.team, B.fname, B.sname
FROM `teams` A, `players` B
WHERE MATCH (B.fname,B.sname) AGAINST ('Derby')
AND A.team_id = B.team_id;

So I have a join here and also some MySQL keywords, I have relations set 
up in my objects


Cheers

Ian



Re: [fw-general] Zend_Db_Table Relationships Delete/Update

2007-07-24 Thread James Dempster

If I understand correctly you would simply extend the Zend_Db_Table_Abstract
as say My_Db_Table and overload the delete and update functions doing
nothing. You would that use this extended class e.g. My_Db_Table as the
table handlers.

I dont quite know why you would want to do this. But heres an example.

class My_Db_Table extends Zend_Db_Table_Abstract {
   public function update($where, $data) {}
   public function date($where) {}
}

class My_Db_Table extends My_Db_Table {
   protected $_name = 'my_table_name';
}

$testTable = new My_Db_Table();
$testTableRowset = $testTable-fetchAll(); // returns all rows

$testTable-update($where, $data); // would call the first update which does
nothing

This is example code only to give an idea.

On 7/24/07, Jack Sleight [EMAIL PROTECTED] wrote:


Hi,
I'm using the database to manage delete and update actions in related
tables, so do I need to tell Zend_Db_Table not to try to emulate these
for me? And if so, how?
Thanks,
--
Jack





--
Regards,
James Dempster

--


Re: [fw-general] Zend_Db_Table Relationships Delete/Update

2007-07-24 Thread Dillon Woods

On 7/24/07, Jack Sleight [EMAIL PROTECTED] wrote:


Hi,
I'm using the database to manage delete and update actions in related
tables, so do I need to tell Zend_Db_Table not to try to emulate these
for me? And if so, how?



Do you mean that you have cascading UPDATE and DELETE rules set up on the
dependent tables in your database?  If your RDBMS supports it, it is
considered a best practice to do what you are doing.  Unless you
specifically declare onUpdate and onDelete variables in your $_referenceMap,
then Zend_Db_Table will not emulate them.  For more information see
http://framework.zend.com/manual/en/zend.db.table.relationships.html#zend.db.table.relationships.cascadingin
the framework documentation.

Dillon


Re: [fw-general] Zend_Db_Table Relationships Delete/Update

2007-07-24 Thread Jack Sleight
Yes the RDBMS supports them (MySQL) so I set them up there. Thanks, just 
wanted to check ZF wouldn't try to do anything automagically.


Dillon Woods wrote:
On 7/24/07, *Jack Sleight* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Do you mean that you have cascading UPDATE and DELETE rules set up on 
the dependent tables in your database?  If your RDBMS supports it, it 
is considered a best practice to do what you are doing.  Unless you 
specifically declare onUpdate and onDelete variables in your 
$_referenceMap, then Zend_Db_Table will not emulate them.  For more 
information see 
http://framework.zend.com/manual/en/zend.db.table.relationships.html#zend.db.table.relationships.cascading 
http://framework.zend.com/manual/en/zend.db.table.relationships.html#zend.db.table.relationships.cascading 
in the framework documentation.


Dillon


--
Jack


RE: [fw-general] Zend_Db_Table Relationships - help

2007-07-22 Thread Bill Karwin
If you have a relationship between two tables, you have a parent and a
dependent by definition.  The dependent contains a foreign key that
references the primary key of its parent.  In the relationship you
described, your parent is product_categories, and your dependent is
products.
 
The SQL table definitions for the relationship you describe might look
like this:
 
CREATE TABLE product_categories (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
);
 
CREATE TABLE products (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
  category_id BIGINT UNSIGNED 
REFERENCES product_categories(id)
);
 
The Zend_Db_Table classes might look like this:
 
// Parent table
class ProductCategoryTable extends Zend_Db_Table_Abstract
{
  protected $_name = 'product_categories';
}
 
// Dependent table contains _referenceMap
class ProductTable extends Zend_Db_Table_Abstract
{
  protected $_name = 'products';
  protected $_referenceMap = array(
'Category' = array(
  'columns' = array('category_id'),
  'refTableClass' = 'ProductCategoryTable'
)
  );
}
 
By default, the referenced column(s) in the parent table are the
column(s) of its primary key, so you don't need to declare 'refColumns'.
 
When you get a row of the ProductCategoryTable, you can iterate through
products that belong to a given category like this:
 
$categoryTable = new ProductCategoryTable();
$categoryRow = $categoryTable-find(123)-current();
$productRowset =
$categoryRow-findDependentRowset('ProductCategoryTable');
foreach ($productRowset as $productRow) {
  // do whatever you want with the row, e.g.:
  print_r($productRow-toArray());
}
 
Regards,
Bill Karwin




From: Matt M. [mailto:[EMAIL PROTECTED] 
Sent: Sunday, July 22, 2007 6:50 AM
To: fw-general@lists.zend.com
Subject: [fw-general] Zend_Db_Table Relationships - help


Hi,

I'm trying to follow the docs but I'm still confused as to what
to do to get relationships going. Here are my models:

Product + ProductTable
ProductCategory + ProductCategoryTable

I don't want cascading actions, so I left out $_dependentTables
as the docs say. 

My tables are setup so products.category_id is a link to the
category the product belongs to. The product_categories table doesn't
have a reference to the product. So:

products.id 
products.category_id

product_categories.id

I want to be able to iterate through the products a category has
and also have access to the category data a product belongs to. With
that, what would my class definitions look like? 

I'm confused with the terminology used in the docs. Dependant
table and parent table don't really fit in here. From my perspective,
neither of these tables are parents.

Anyone want to post a simple set of classes that would enable
the functionality I'm seeking? :) 
Matt




RE: [fw-general] Zend_Db_Table Relationships - help

2007-07-22 Thread Bill Karwin
Sorry!  My mistake - this should be findDependentRowset('ProductTable');
 
Bill Karwin




From: Bill Karwin [mailto:[EMAIL PROTECTED] 

$productRowset =
$categoryRow-findDependentRowset('ProductCategoryTable'); 
 
 



Re: [fw-general] Zend_Db_Table

2007-03-15 Thread Simon Mundy
Wait for a couple of days and you'll see Zend_Db_Table_Row::delete()  
in the trunk :)


You can always use the existing Zend_Db_Table::delete() but you need  
to supply your own where condition for it to remove rows by id.



Hello guys.

What about implement method drop($id) for Zend_Db_Table for remove  
records using primary id?

Or/and drop() method for Zend_Db_Table_Row class?

--
Thanks, Dmitry


--

Simon Mundy | Director | PEPTOLAB


202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654  
4124

http://www.peptolab.com




Re: [fw-general] Zend_Db_Table

2006-10-10 Thread Abu Hurayrah
Since you've brought it up, is there anywhere where I can see the 
explanation/justification given for this automatic routine?  I think it 
makes ZF a lot harder to work with when you use it with older systems 
where the schema name system may be a mix of different 
styles...StudlyCaps, camelCase, underscore_separated, or allinone.  
Short of rewriting the __get()  __set() methods for each class/object 
you want to use, is there any other easy way to handle this?


Abu Hurayrah
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
Hidayah Online - Guidance According to the Qur'an and Sunnah 
http://hidayahonline.org/
`A'isha, the wife of Allah's Apostle (may peace be upon him), reported 
Allah's Apostle (may peace be upon him) as saying:
/Kindness is not to be found in anything but that it adds to its beauty 
and it is not withdrawn from anything but it makes it defective./

narrated in Sahih Muslim, Book 3, Number 6274


gonyuu wrote:

I think what Bruno is referring to is the camel-case renaming of the fields
in Zend_Db_Row; i.e. zend_field gets mapped as zendField. I ran into the
same problems when I had fields named ZendField. I basically couldn't
access these fields because of the case sensitivity in MySQL (zendfield
would not work). My solution thus far has been to bear with lower-case field
names :(

gonyuu


Terry Cullen wrote:
  

The manual:


?php
class ClassName extends Zend_Db_Table
{
// default table name is 'class_name'
// but we want to map to something else
protected $_name = 'another_table_name';
}
?



On 10/2/06, Bruno Viana [EMAIL PROTECTED] wrote:


I use the Zend_Db_Table with a test table, it works fine.. but when i use
table of my old app that fields are in upper case it's don't work, but i
rewrite my fields to lower case it works.

I had to rewrite all my fields to lower case or have a fix (or work
around) to this?

--
Fui para os bosques viver de livre vontade. Para sugar todo o tutano da
vida, para aniquilar tudo o que não era vida e para, quando morrer, não
descobrir que não vivi.
  



  


Re: [fw-general] Zend_Db_Table

2006-10-10 Thread Gavin Vess

This is recognized as an issue:
http://framework.zend.com/issues/browse/ZF-50

We are going to propose introducing a name filter for database names, 
table names, and column names, with a default behavior.  The default 
behavior will be no filtering or modification of these names  (i.e. no 
more camelCase).  Users will then be able to select whatever name 
filter they need for their particular circumstances, if the default 
doesn't work.


Cheers,
Gavin

Which ZF List?
=
Everything, except the topics below: fw-general@lists.zend.com

Authorization, Authentication, ACL, Access Control, Session Management
[EMAIL PROTECTED]

Tests, Caching, Configuration, Environment, Logging
[EMAIL PROTECTED]

All things related to databases
[EMAIL PROTECTED]

Documentation, Translations, Wiki Manual / Tutorials
[EMAIL PROTECTED]

Internationalization  Localization, Dates, Calendar, Currency, Measure
[EMAIL PROTECTED]

Mail, MIME, PDF, Search, data formats (JSON, ...)
[EMAIL PROTECTED]

MVC, Controller, Router, Views, Zend_Request*
[EMAIL PROTECTED]

Community Servers/Services (shell account, PEAR channel, Jabber)
[EMAIL PROTECTED]

Web Services  Servers (HTTP, SOAP, Feeds, XMLRPC, REST)
[EMAIL PROTECTED]


How to subscribe:  http://framework.zend.com/wiki/x/GgE

Abu Hurayrah wrote:
Since you've brought it up, is there anywhere where I can see the 
explanation/justification given for this automatic routine?  I think 
it makes ZF a lot harder to work with when you use it with older 
systems where the schema name system may be a mix of different 
styles...StudlyCaps, camelCase, underscore_separated, or allinone.  
Short of rewriting the __get()  __set() methods for each class/object 
you want to use, is there any other easy way to handle this?


Abu Hurayrah
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
Hidayah Online - Guidance According to the Qur'an and Sunnah 
http://hidayahonline.org/
`A'isha, the wife of Allah's Apostle (may peace be upon him), reported 
Allah's Apostle (may peace be upon him) as saying:
/Kindness is not to be found in anything but that it adds to its 
beauty and it is not withdrawn from anything but it makes it defective./

narrated in Sahih Muslim, Book 3, Number 6274


gonyuu wrote:
I think what Bruno is referring to is the camel-case renaming of the 
fields
in Zend_Db_Row; i.e. zend_field gets mapped as zendField. I ran 
into the

same problems when I had fields named ZendField. I basically couldn't
access these fields because of the case sensitivity in MySQL 
(zendfield
would not work). My solution thus far has been to bear with 
lower-case field

names :(

gonyuu


Terry Cullen wrote:
 

The manual:


?php
class ClassName extends Zend_Db_Table
{
// default table name is 'class_name'
// but we want to map to something else
protected $_name = 'another_table_name';
}
?



On 10/2/06, Bruno Viana [EMAIL PROTECTED] wrote:
   
I use the Zend_Db_Table with a test table, it works fine.. but when 
i use
table of my old app that fields are in upper case it's don't work, 
but i

rewrite my fields to lower case it works.

I had to rewrite all my fields to lower case or have a fix (or work
around) to this?

--
Fui para os bosques viver de livre vontade. Para sugar todo o 
tutano da
vida, para aniquilar tudo o que não era vida e para, quando morrer, 
não

descobrir que não vivi.
  



  







Re: [fw-general] Zend_Db_Table

2006-10-10 Thread Bruno Viana
Lewt me explain better what i asked. I have a field called NAME (in upper case), but the Zend mapping don't see it when i use Zend_Db_Table. So, when i write in lower case( name ), thats works.
On 10/10/06, Abu Hurayrah [EMAIL PROTECTED] wrote:
Since you've brought it up, is there anywhere where I can see theexplanation/justification given for this automatic routine?I think itmakes ZF a lot harder to work with when you use it with older systemswhere the schema name system may be a mix of different
styles...StudlyCaps, camelCase, underscore_separated, or allinone.Short of rewriting the __get()  __set() methods for each class/objectyou want to use, is there any other easy way to handle this?Abu Hurayrah
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]Hidayah Online - Guidance According to the Qur'an and Sunnah
http://hidayahonline.org/`A'isha, the wife of Allah's Apostle (may peace be upon him), reportedAllah's Apostle (may peace be upon him) as saying:/Kindness is not to be found in anything but that it adds to its beauty
and it is not withdrawn from anything but it makes it defective./narrated in Sahih Muslim, Book 3, Number 6274gonyuu wrote: I think what Bruno is referring to is the camel-case renaming of the fields
 in Zend_Db_Row; i.e. zend_field gets mapped as zendField. I ran into the same problems when I had fields named ZendField. I basically couldn't access these fields because of the case sensitivity in MySQL (zendfield
 would not work). My solution thus far has been to bear with lower-case field names :( gonyuu Terry Cullen wrote: The manual:
 ?php class ClassName extends Zend_Db_Table { // default table name is 'class_name' // but we want to map to something else protected $_name = 'another_table_name';
 } ? On 10/2/06, Bruno Viana [EMAIL PROTECTED] wrote: I use the Zend_Db_Table with a test table, it works fine.. but when i use
 table of my old app that fields are in upper case it's don't work, but i rewrite my fields to lower case it works. I had to rewrite all my fields to lower case or have a fix (or work
 around) to this? -- Fui para os bosques viver de livre vontade. Para sugar todo o tutano da vida, para aniquilar tudo o que não era vida e para, quando morrer, não
 descobrir que não vivi.-- Fui para os bosques viver de livre vontade. Para sugar todo o tutano da vida, para aniquilar tudo o que não era vida e para, quando morrer, não descobrir que não vivi.


Re: [fw-general] Zend_Db_Table

2006-10-10 Thread gonyuu

As an aside, where can I find out when these changes are officially
implemented (i.e. when they will appear in the latest snapshot/nightly
build)? Do I just have to follow the issue tracker?

Thanks, gonyuu.


GavinZend wrote:
 
 This is recognized as an issue:
 http://framework.zend.com/issues/browse/ZF-50
 
 We are going to propose introducing a name filter for database names, 
 table names, and column names, with a default behavior.  The default 
 behavior will be no filtering or modification of these names  (i.e. no 
 more camelCase).  Users will then be able to select whatever name 
 filter they need for their particular circumstances, if the default 
 doesn't work.
 
 Cheers,
 Gavin
 
 Which ZF List?
 =
 Everything, except the topics below: fw-general@lists.zend.com
 
 Authorization, Authentication, ACL, Access Control, Session Management
 [EMAIL PROTECTED]
 
 Tests, Caching, Configuration, Environment, Logging
 [EMAIL PROTECTED]
 
 All things related to databases
 [EMAIL PROTECTED]
 
 Documentation, Translations, Wiki Manual / Tutorials
 [EMAIL PROTECTED]
 
 Internationalization  Localization, Dates, Calendar, Currency, Measure
 [EMAIL PROTECTED]
 
 Mail, MIME, PDF, Search, data formats (JSON, ...)
 [EMAIL PROTECTED]
 
 MVC, Controller, Router, Views, Zend_Request*
 [EMAIL PROTECTED]
 
 Community Servers/Services (shell account, PEAR channel, Jabber)
 [EMAIL PROTECTED]
 
 Web Services  Servers (HTTP, SOAP, Feeds, XMLRPC, REST)
 [EMAIL PROTECTED]
 
 
 How to subscribe:  http://framework.zend.com/wiki/x/GgE
 
 Abu Hurayrah wrote:
 Since you've brought it up, is there anywhere where I can see the 
 explanation/justification given for this automatic routine?  I think 
 it makes ZF a lot harder to work with when you use it with older 
 systems where the schema name system may be a mix of different 
 styles...StudlyCaps, camelCase, underscore_separated, or allinone.  
 Short of rewriting the __get()  __set() methods for each class/object 
 you want to use, is there any other easy way to handle this?

 Abu Hurayrah
 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
 Hidayah Online - Guidance According to the Qur'an and Sunnah 
 http://hidayahonline.org/
 `A'isha, the wife of Allah's Apostle (may peace be upon him), reported 
 Allah's Apostle (may peace be upon him) as saying:
 /Kindness is not to be found in anything but that it adds to its 
 beauty and it is not withdrawn from anything but it makes it defective./
 narrated in Sahih Muslim, Book 3, Number 6274


 gonyuu wrote:
 I think what Bruno is referring to is the camel-case renaming of the 
 fields
 in Zend_Db_Row; i.e. zend_field gets mapped as zendField. I ran 
 into the
 same problems when I had fields named ZendField. I basically couldn't
 access these fields because of the case sensitivity in MySQL 
 (zendfield
 would not work). My solution thus far has been to bear with 
 lower-case field
 names :(

 gonyuu


 Terry Cullen wrote:
  
 The manual:


 ?php
 class ClassName extends Zend_Db_Table
 {
 // default table name is 'class_name'
 // but we want to map to something else
 protected $_name = 'another_table_name';
 }
 ?



 On 10/2/06, Bruno Viana [EMAIL PROTECTED] wrote:

 I use the Zend_Db_Table with a test table, it works fine.. but when 
 i use
 table of my old app that fields are in upper case it's don't work, 
 but i
 rewrite my fields to lower case it works.

 I had to rewrite all my fields to lower case or have a fix (or work
 around) to this?

 -- 
 Fui para os bosques viver de livre vontade. Para sugar todo o 
 tutano da
 vida, para aniquilar tudo o que não era vida e para, quando morrer, 
 não
 descobrir que não vivi.
   
 

   


 
 
 

-- 
View this message in context: 
http://www.nabble.com/Zend_Db_Table-tf2369500s16154.html#a6748917
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Db_Table is not a base for a model in MVC

2006-09-28 Thread Pavel Shevaev

On 9/28/06, Davey Shafik [EMAIL PROTECTED] wrote:

Uh

__CLASS__



Not really, here's how it all started
http://www.sitepoint.com/forums/showthread.php?t=334377


- Davey

--
Best regards, Pavel
--
LIMB - http://limb-project.com
Bureau of Information Technologies - http://www.bit-creative.com


Re: [fw-general] Zend_Db_Table is not a base for a model in MVC

2006-09-28 Thread Daniel Kipp

 Basically, this is impossibility (in PHP) to get the class name inside
 of a static method

hi all

I don't know if this was already mentioned but the php developers agreed 
on changing

that behavior in the future versions. (there called it: late static binding)
here is the thread in there mailing list:

http://marc.theaimsgroup.com/?t=11418520931r=1w=2

and this is the blog entry of a developer who looks like he is involved.
http://www.digitalsandwich.com/archives/53-Late-Static-Binding-in-PHP.html




Re: [fw-general] Zend_Db_Table is not a base for a model in MVC

2006-09-28 Thread Dale McNeill
IMO, data validation should not be performed within the model but rather 
in the controller.  The controller could query the Table/Row for 
validator objects but its the controller that should perform all the 
validating of data.


One thing that I would like to see in a future Zend_Db_Table is the 
storage of the entire describe table rather than only storing the 
column names.  Why? Well I've changed the Table to store this 
information so that the controller can query the Table for the 
fundamental validator objects.  A varchar(30) can provide a validator 
that restricts the the length to 30 characters; a int(10) can provide 
an integer validator that restricts the maximum value to a 10 digit 
signed integer.  I think in general the results of the describe table is 
very useful and certainly worth storing all the information.  It could 
even be used to set the default values of any unset columns when 
performing an insert.


Dale

Stuardo -StR- Rodríguez wrote:

On Wednesday 27 September 2006 00:47, Victor Bolshov wrote:
  

Could you please tell in more detail - what you mean by a model in MVC?



I mean a model, in the context of Model-View-Controller. As you can see in 
http://en.wikipedia.org/wiki/Model-view-controller 


blockquote
Model: The domain-specific representation of the information on which the 
application operates. The model is another name for the domain layer. Domain 
logic adds meaning to raw data (e.g., calculating if today is the user's 
birthday, or the totals, taxes and shipping charges for shopping cart items).

/blockquote

So.. from where I see.. the controller should create a model to get data or to 
return data, from wherever you want (DB, XML, RPC, log, etc). The controller 
should know the action what should be done, the bussiness logic. The model 
should know what to do with the data, validate the data, and all what is 
related with data.


Now, I do not see any solution for that in ZF and I thought Zend_Db_Table 
could be use as a solution, but I was wrong and I started the post to see if 
anyone had the same idea and if anyone has solved that.


I said Model in MVC to let people understand the context, so no one gets 
confused with a model/guide to follow or a hot-long-legs-model




  


Re: [fw-general] Zend_Db_Table is not a base for a model in MVC

2006-09-28 Thread Jean-Baptiste HUNTZINGER




 MO, data validation should not be performed within the model
but rather in the controller
There is definitively many opinions about Validation in MVC, but I
still don't agree with your statement. I want a solution that does not
oblige me to rewrite my validation code each time my View changes -
either I change the UI logic or the client technology -, since
controller is tighly bound to the view.
Model has all the info needed to performs the validation, and
validation is purely domain logic, no ?

Dale McNeill a écrit :
IMO,
data validation should not be performed within the model but rather in
the controller.  The controller could query the Table/Row for validator
objects but its the controller that should perform all the validating
of data.
  
  
One thing that I would like to see in a future Zend_Db_Table is the
storage of the entire "describe table" rather than only storing
the column names.  Why? Well I've changed the Table to store this
information so that the controller can query the Table for the
fundamental validator objects.  A "varchar(30)" can provide a validator
that restricts the the length to 30 characters; a "int(10)" can provide
an integer validator that restricts the maximum value to a 10 digit
signed integer.  I think in general the results of the describe table
is very useful and certainly worth storing all the information.  It
could even be used to set the default values of any unset columns when
performing an insert.
  
  
Dale
  
  
Stuardo -StR- Rodríguez wrote:
  
  On Wednesday 27 September 2006 00:47, Victor
Bolshov wrote:

 
Could you please tell in more detail - what
you mean by "a model in MVC"?
  
    

I mean a model, in the context of Model-View-Controller. As you can see
in http://en.wikipedia.org/wiki/Model-view-controller 
blockquote

Model: The domain-specific representation of the information on which
the application operates. The model is another name for the domain
layer. Domain logic adds meaning to raw data (e.g., calculating if
today is the user's birthday, or the totals, taxes and shipping charges
for shopping cart items).

/blockquote


So.. from where I see.. the controller should create a model to get
data or to return data, from wherever you want (DB, XML, RPC, log,
etc). The controller should know "the action" what should be done, the
bussiness logic. The model should know what to do with the data,
validate the data, and all what is related with data.


Now, I do not see any solution for that in ZF and I thought
Zend_Db_Table could be use as a solution, but I was wrong and I started
the post to see if anyone had the same idea and if anyone has solved
that.


I said "Model in MVC" to let people understand the context, so no one
gets confused with "a model/guide to follow" or "a hot-long-legs-model"




  


-- 
Jean-Baptiste HUNTZINGER





Re: [fw-general] Zend_Db_Table is not a base for a model in MVC

2006-09-28 Thread Justin Hendrickson
The problem still remains that you can't call a derived classes static method in the base class.abstract class ActiveRecord { abstract static public function getTable(); static public function find() {
 echo self::getTable(); }}class Person extends ActiveRecord { static public function getTable() { return __CLASS__; }}Person::find();Fatal error: Cannot call abstract method ActiveRecord::getTable() in /home/jhendric/test.php on line 7
Call Stack: 0.0004 40688 1. {main}() /home/jhendric/test.php:0 0.0005 40688 2. ActiveRecord::find() /home/jhendric/test.php:20On 9/28/06, 
Matthew Weier O'Phinney [EMAIL PROTECTED] wrote:
-- Davey Shafik [EMAIL PROTECTED] wrote(on Thursday, 28 September 2006, 10:20 AM -0400): And that'll teach me to jump in on a conversation :) What about implementing an interface which specifies a getTable()
 method, then don't implement it in an Abstract AR class. That way when you extend, you write in a: function getTable() { return __CLASS__; }
 or you can even do: function getTable() { return Somethingcompletelydifferent; } I dislike this idea, I prefer just to instantiate the AR class and
 use it as an object :)This type of solution was discussed at one point. I believe it wasrejected because many felt it added what could be construed as one steptoo many in development. Instead of simply:
class MyTable extends Zend_Db_Table {}the developer now has to do:class MyTable extends Zend_Db_Table{public static function getTable(){return __CLASS__;
}}Admittedly not a lot of code, but it's another vector for introducingerrors.I'm not exactly sure where my own preference lies, personally. On Sep 28, 2006, at 10:03 AM, Pavel Shevaev wrote:
  On 9/28/06, Davey Shafik [EMAIL PROTECTED] wrote:   Uh __CLASS__  
   Not really, here's how it all started  http://www.sitepoint.com/forums/showthread.php?t=334377--Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]Zend - The PHP Company | http://www.zend.com/


Re: [fw-general] Zend_Db_Table is not a base for a model in MVC

2006-09-27 Thread Victor Bolshov

Michael Yevdokimov wrote:

Hello Victor,
 
Could you please explain what the Model should be or how it should be 
presented in ZF in your opinion?
Example is simple: I would like to use the model the same way as I do it 
in Rails, i.e. putting all the database manipulations and data 
validation into it.
 
Thank you very much in advance.
 


One cannot simply port Rails-ActiveRecord to PHP (there are certain 
features used that are not yet implemented in PHP, possibly will be in 
PHP6).


In *my* opinion, a model, indeed, should look like that of Rails. In 
LIMB-project ( http://limb-project.com ) they've recently have made a 
step towards making their model much like Rails' one. You may also take 
look at php-doctrine.


But the *original* question was about a model in MVC. To me, it looks 
like a senseless set of words. In MVC you are free to use any kind of 
model. Zend_Db_* does *NOT* provide you with an ActiveRecord, nor does 
it provide a means for validation and object-relational mapping. It is 
*just* what it is: a DBAL, a query-object, a Table-gateway and a 
Row-gateway. You may use it your application, and your application is 
free to acquire MVC architecture or some other architecture as well.


Although there is sometimes a need for an advanced ORM in an 
application, the means provided by Zend_Db_*, should, as I believe, 
satisfy developer in 80-90% of cases. And, there is a strong doubt that 
a large-and-heavy ORM tool could really solve all the problems regarding 
application-RDBMS relation.


Regards,

Victor.

PS. The question you have asked (if before we refer to the original 
question), should not be what the Model should be or how it should be 
presented in *ZF* in your opinion? - but instead what the Model should 
be or how it should be presented in *MVC* in your opinion?. I cannot 
answer this question, and think nobody can.


smime.p7s
Description: S/MIME Cryptographic Signature


Re: [fw-general] Zend_Db_Table is not a base for a model in MVC

2006-09-27 Thread Markus Wolff

Victor Bolshov schrieb:
One cannot simply port Rails-ActiveRecord to PHP (there are certain 
features used that are not yet implemented in PHP, possibly will be in 
PHP6).


Hi Victor,

Just out of curiosity: What features do you think these are?

CU
 Markus


Re: [fw-general] Zend_Db_Table is not a base for a model in MVC

2006-09-27 Thread Michael Yevdokimov

Hi again
This is all interesting. So basically you mean that there can not be
no such a term in MVC for PHP, like there is for ROR? I am curious
what you think about Propel as a tool to 'emulate' models in php mvc?
Though I would still agree that this is again just an ORM and not more
than that.

To be honest, I do not use any of these ORM things. I am still making
SQL queries myself or with some visual software.

I created my own 'model controller' with the methods like insert,
delete, etc. which actually just creating queries which are being sent
later to ADODB php library. so from this 'model controller' I inherit
all my models.

Otherwise, I think there will be too much mass in my code.

I am curious what others do with the missing Model Controller?? ;)

Cheers,
Mikhail


On 9/27/06, Victor Bolshov [EMAIL PROTECTED] wrote:

Michael Yevdokimov wrote:
 Hello Victor,

 Could you please explain what the Model should be or how it should be
 presented in ZF in your opinion?
 Example is simple: I would like to use the model the same way as I do it
 in Rails, i.e. putting all the database manipulations and data
 validation into it.

 Thank you very much in advance.


One cannot simply port Rails-ActiveRecord to PHP (there are certain
features used that are not yet implemented in PHP, possibly will be in
PHP6).

In *my* opinion, a model, indeed, should look like that of Rails. In
LIMB-project ( http://limb-project.com ) they've recently have made a
step towards making their model much like Rails' one. You may also take
look at php-doctrine.

But the *original* question was about a model in MVC. To me, it looks
like a senseless set of words. In MVC you are free to use any kind of
model. Zend_Db_* does *NOT* provide you with an ActiveRecord, nor does
it provide a means for validation and object-relational mapping. It is
*just* what it is: a DBAL, a query-object, a Table-gateway and a
Row-gateway. You may use it your application, and your application is
free to acquire MVC architecture or some other architecture as well.

Although there is sometimes a need for an advanced ORM in an
application, the means provided by Zend_Db_*, should, as I believe,
satisfy developer in 80-90% of cases. And, there is a strong doubt that
a large-and-heavy ORM tool could really solve all the problems regarding
application-RDBMS relation.

Regards,

Victor.

PS. The question you have asked (if before we refer to the original
question), should not be what the Model should be or how it should be
presented in *ZF* in your opinion? - but instead what the Model should
be or how it should be presented in *MVC* in your opinion?. I cannot
answer this question, and think nobody can.





--
Michael Yevdokimov
E-mail: [EMAIL PROTECTED]
Tel. +31 (0) 61 4599307


Re: [fw-general] Zend_Db_Table is not a base for a model in MVC

2006-09-26 Thread Victor Bolshov

Could you please tell in more detail - what you mean by a model in MVC?


smime.p7s
Description: S/MIME Cryptographic Signature