Re: regarding using dynamic table name in controller function

2012-08-30 Thread Dr. Tarique Sani
Use SHOW COLUMNS $table_name

Read more http://dev.mysql.com/doc/refman/5.0/en/show-columns.html

HTH
Tarique

On Thu, Aug 30, 2012 at 11:45 AM, Vaibhav.Pathak  wrote:
> Hi,
>
> i am facing an problem in my application, problem is that i am creating an
> function in which i have to find all fields name in particular database
> table using an function and name of the table is dynamic everytime like the
> case:
> function abc($table_name)
> {
>$table_field=$this->$table_name->find('all');
>$this->set('$table_field' ,$table_field);
> }
>
> Please  help me.
>
> Thanks
> Vaibhav Pathak
>
> --
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>
>



-- 
=
PHP for E-Biz: http://sanisoft.com
=

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: regarding using dynamic table name in controller function

2012-08-30 Thread Chetan Patel
Hello friends,

Try below action

function abc($table_name)
{
   $model_name = Inflector::classify($table_name)

   App::Import('Model', $model_name);
   $this->DynamicModel = new $model_name;

   $table_field=$this->DynamicModel->find('all');
   $this->set('$table_field' ,$table_field);

}


-- 
Thanks & Regards

Chetan Patel

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




regarding using dynamic table name in controller function

2012-08-30 Thread Vaibhav.Pathak
Hi,

i am facing an problem in my application, problem is that i am creating an 
function in which i have to find all fields name in particular database 
table using an function and name of the table is dynamic everytime like the 
case:
function abc($table_name)
{
   $table_field=$this->$table_name->find('all');
   $this->set('$table_field' ,$table_field);
}

Please  help me.

Thanks
Vaibhav Pathak 

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: Dynamic table with cakephp

2011-04-21 Thread Otavio Martins Salomao
That your table need be in the cakephp convetion, so the name of table in
plural and model on singular

2011/4/20 cricket 

> On Wed, Apr 20, 2011 at 11:33 AM, gannher  wrote:
> > Hello
> >
> > My application must create table. It will be done with procedure/
> > function in mysql. So cakephp doesn't need to send query "create
> > table...".
> >
> > How can I use this table with cakephp ? Must I create file model and
> > how ? I would like use function find, paginate, etc with this table.
>
> $this->YourModelName->setSource('your_table_name');
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Dynamic table with cakephp

2011-04-21 Thread gannher


On 21 avr, 10:23, Jeremy Burns | Class Outfit
 wrote:
> Please show some more of your code - we're in the dark a bit about what you 
> are trying to do.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 21 Apr 2011, at 09:21, gannher wrote:
>
>
>
>
>
>
>
>
>
> > On 20 avr, 18:30, cricket  wrote:
> >> On Wed, Apr 20, 2011 at 11:33 AM, gannher  wrote:
> >>> Hello
>
> >>> My application must create table. It will be done with procedure/
> >>> function in mysql. So cakephp doesn't need to send query "create
> >>> table...".
>
> >>> How can I use this table with cakephp ? Must I create file model and
> >>> how ? I would like use function find, paginate, etc with this table.
>
> >> $this->YourModelName->setSource('your_table_name');
>
> > Hello
>
> > With this solution i have :
>
> > Missing Database Table
>
> > Error: Database table debug for model Undefine was not found.
>
> > --
> > Our newest site for the community: CakePHP Video 
> > Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php

Hello

Sorry $this->YourModelName->setSource('your_table_name'); are the good
solution. I mistake with my table_name so cakephp send me an error.

Thanks for your help and your rapidity.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Dynamic table with cakephp

2011-04-21 Thread hunny
Create a model file (lets call it Dynamic)


In your Controller, you can use $this->Dynamic->useTable =
'YOUR_TABLE_NAME';



Thanks.








On Apr 21, 1:23 pm, Jeremy Burns | Class Outfit
 wrote:
> Please show some more of your code - we're in the dark a bit about what you 
> are trying to do.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 21 Apr 2011, at 09:21, gannher wrote:
>
>
>
>
>
>
>
>
>
> > On 20 avr, 18:30, cricket  wrote:
> >> On Wed, Apr 20, 2011 at 11:33 AM, gannher  wrote:
> >>> Hello
>
> >>> My application must create table. It will be done with procedure/
> >>> function in mysql. So cakephp doesn't need to send query "create
> >>> table...".
>
> >>> How can I use this table with cakephp ? Must I create file model and
> >>> how ? I would like use function find, paginate, etc with this table.
>
> >> $this->YourModelName->setSource('your_table_name');
>
> > Hello
>
> > With this solution i have :
>
> > Missing Database Table
>
> > Error: Database table debug for model Undefine was not found.
>
> > --
> > Our newest site for the community: CakePHP Video 
> > Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Dynamic table with cakephp

2011-04-21 Thread Jeremy Burns | Class Outfit
Please show some more of your code - we're in the dark a bit about what you are 
trying to do.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 21 Apr 2011, at 09:21, gannher wrote:

> 
> 
> On 20 avr, 18:30, cricket  wrote:
>> On Wed, Apr 20, 2011 at 11:33 AM, gannher  wrote:
>>> Hello
>> 
>>> My application must create table. It will be done with procedure/
>>> function in mysql. So cakephp doesn't need to send query "create
>>> table...".
>> 
>>> How can I use this table with cakephp ? Must I create file model and
>>> how ? I would like use function find, paginate, etc with this table.
>> 
>> $this->YourModelName->setSource('your_table_name');
> 
> Hello
> 
> With this solution i have :
> 
> Missing Database Table
> 
> Error: Database table debug for model Undefine was not found.
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
> 
> 
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Dynamic table with cakephp

2011-04-21 Thread gannher


On 21 avr, 10:21, gannher  wrote:
> On 20 avr, 18:30, cricket  wrote:
>
> > On Wed, Apr 20, 2011 at 11:33 AM, gannher  wrote:
> > > Hello
>
> > > My application must create table. It will be done with procedure/
> > > function in mysql. So cakephp doesn't need to send query "create
> > > table...".
>
> > > How can I use this table with cakephp ? Must I create file model and
> > > how ? I would like use function find, paginate, etc with this table.
>
> > $this->YourModelName->setSource('your_table_name');
>
> Hello
>
> With this solution i have :
>
> Missing Database Table
>
> Error: Database table debug for model Undefine was not found.

And to use $this->YourModelName->setSource('your_table_name'); , I
need a model class. I don't have this model class because the the has
been create dynamicly

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Dynamic table with cakephp

2011-04-21 Thread gannher


On 20 avr, 18:30, cricket  wrote:
> On Wed, Apr 20, 2011 at 11:33 AM, gannher  wrote:
> > Hello
>
> > My application must create table. It will be done with procedure/
> > function in mysql. So cakephp doesn't need to send query "create
> > table...".
>
> > How can I use this table with cakephp ? Must I create file model and
> > how ? I would like use function find, paginate, etc with this table.
>
> $this->YourModelName->setSource('your_table_name');

Hello

With this solution i have :

Missing Database Table

Error: Database table debug for model Undefine was not found.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Dynamic table with cakephp

2011-04-20 Thread cricket
On Wed, Apr 20, 2011 at 11:33 AM, gannher  wrote:
> Hello
>
> My application must create table. It will be done with procedure/
> function in mysql. So cakephp doesn't need to send query "create
> table...".
>
> How can I use this table with cakephp ? Must I create file model and
> how ? I would like use function find, paginate, etc with this table.

$this->YourModelName->setSource('your_table_name');

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Dynamic table with cakephp

2011-04-20 Thread gannher
Hello

My application must create table. It will be done with procedure/
function in mysql. So cakephp doesn't need to send query "create
table...".

How can I use this table with cakephp ? Must I create file model and
how ? I would like use function find, paginate, etc with this table.

Thanks

Gannher

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Dynamic table

2007-12-04 Thread Adam Royle

Ahhh... I think I now understand what you're saying. Initially I
thought you meant creating tables in the actual database and I'm
sure everyone else thought the same.

But re-reading your question I now think you mean *HTML* tables. Is
that correct?

OK... I would achieve the effect you want using ajax...

Here is the code you would put in your view for model A. You could
probably do the same with cakephp helpers but this is easy enough to
understand.


/views/modela/add.ctp



function addB(){
new Ajax.Updater('mytable', '/ModelB/blank_row/',
{insertion:Insertion.Bottom});
}



create('ModelA') ?>









end() ?>









And then in your view you would output the new row like so

/views/modelb/blank_row.ctp


create("ModelB.field1") ?>
create("ModelB.field2") ?>
create("ModelB.field3") ?>



And that code should fit together nicely

HOWEVER the only thing left to consider is making sure the field
names and ids are not duplicated and are in a format cakephp can
handle when saving.

(note: cakephp doesn't automatically save hasMany associations... so
you'll need the saveHasMany() function included at the bottom of this
email.)


The saveHasMany() function expects form input field names to be in a
format like this:










Unfortunately in the blank_row.ctp above the form helper will create
fields like this.. which will obviously not work...



The way to solve this is to pass an extra argument when requesting the
blank row, using javascript to keep track of the counter_var.. eg


var counter_var = 0;
function addB(){
new Ajax.Updater('mytable', '/modelb/blank_row/'+(counter_var++),
{insertion:Insertion.Bottom});
}


Then modify your controller to pass this through to the view to use.

function blank_row($index){
$this->set('index', intval($index));
}

(another note: currently you can't overwrite the fieldname when using
the form helper, so my suggestion is to overwrite the $form->Html-
>tags['***'] array)

Html->tags['input'] = '';
$form->Html->tags['hidden'] = '';

// ... you get the idea... you can find the rest defined inside /cake/
libs/view/helpers/html.php

?>

input('field1', array('id' => 'ModelB'.
$index.'field1')); ?>
input('field2', array('id' => 'ModelB'.
$index.'field2')); ?>
input('field3', array('id' => 'ModelB'.
$index.'field3')); ?>







And finally here is the saveHasMany() method that goes into your
app_model.php file

class AppModel extends Model {

function saveHasMany($k) {
$success = true;

$v = $this->hasMany[$k];

$myid = $this->data[$this->name][$this->primaryKey] ? $this-
>data[$this->name][$this->primaryKey] : $this->id;
$deletequery = "DELETE FROM {$this->$k->useTable} WHERE
{$v['foreignKey']} = {$myid}";
$db =& ConnectionManager::getDataSource($this->$k->useDbConfig);
$db->query($deletequery);

if (!isset($this->data[$k]) || empty($this->data[$k])) {
return $success;
}

// Save new data
foreach ($this->data[$k] as $tc) {
$tc[$v['foreignKey']] = $myid;
$data[$v['className']] = $tc;
$this->{$v['className']}->create($data);
if (!$this->{$v['className']}->save()) {
$success = false;
}
}

return $success;
}

}


and use it in your model like:

class ModelA extends AppModel {

... blah associations, etc ...

function afterSave(){
$this->saveHasMany('ModelB');
}

}


On Dec 4, 9:03 pm, dandreta <[EMAIL PROTECTED]> wrote:
> Nobody knows any link or example how I can do it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic table

2007-12-04 Thread dandreta

Nobody knows any link or example how I can do it?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic table

2007-11-27 Thread dandreta



On 26 nov, 19:22, rtconner <[EMAIL PROTECTED]> wrote:
> If it was me, I'd have a Model with no table attatched and then add a
> function to create the tables in it
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic table

2007-11-26 Thread rtconner

If it was me, I'd have a Model with no table attatched and then add a
function to create the tables in it
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic table

2007-11-26 Thread Christopher E. Franklin, Sr.

I think here, you are going to have to "roll your own" sql statements
within the function of the controller.

On Nov 26, 10:01 am, dandreta <[EMAIL PROTECTED]> wrote:
> I have two models:ModelA and Model B.
> ModelA hasMany ModelB.
> In the add view of ModelA, I want to create a table dynamically with a
> button(AddB) and clicking it, adds a new row with the inputs of the
> fields of the ModelB.
> At the end of the view I have a submit button and I want that on
> clicking it, all B elements  that I have introduced will store in the
> database  .
> How can I do it?
> Any link or suggestion?
> Thanks and regards
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Dynamic table

2007-11-26 Thread dandreta

I have two models:ModelA and Model B.
ModelA hasMany ModelB.
In the add view of ModelA, I want to create a table dynamically with a
button(AddB) and clicking it, adds a new row with the inputs of the
fields of the ModelB.
At the end of the view I have a submit button and I want that on
clicking it, all B elements  that I have introduced will store in the
database  .
How can I do it?
Any link or suggestion?
Thanks and regards
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: dynamic table names in wordpress

2006-11-09 Thread georgeL

wp mu is just changeing the prefix of the tables. you can also set the
table prefix inside cake somewhere. maybe this is a possible way


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: dynamic table names in wordpress

2006-11-09 Thread [EMAIL PROTECTED]

HmmCan't he change the $useTable variable to reflect the name of
the table he is working with? Or does that var have to be set before
the class is loaded?

On Nov 9, 5:08 pm, "mozey" <[EMAIL PROTECTED]> wrote:
> unfortunat. But, it sure did help. thank you.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: dynamic table names in wordpress

2006-11-09 Thread mozey

unfortunat. But, it sure did help. thank you.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: dynamic table names in wordpress

2006-11-08 Thread Chris Hartjes

On 11/8/06, mozey <[EMAIL PROTECTED]> wrote:
>
> still not having any luck with this guys, any input?
>
>

You won't be able to use the built-in db model stuff if you have
constantly changing table  names.  That would require changes to the
model classes themselves, which is likely a topic way beyond the
capacity of most of the people who are on this list.

I know it's not much of an answer, but that's the most likely scenario.

Perhaps Nate and PHPNut can suggest something, but I suspect their
answer would be the same as mine.

Hope that helps, and good luck.

-- 
Chris Hartjes

"The greatest inefficiencies come from solving problems you will never have."
-- Rasmus Lerdorf

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: dynamic table names in wordpress

2006-11-08 Thread mozey

still not having any luck with this guys, any input?


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



dynamic table names in wordpress

2006-11-03 Thread mozey

i'm working on writing plugins for the multiuser version of wordpress.
Which creates a whole bunch of new tables for everyuser. By default, it
produces 8 tables for each user, my plugin will add two more, but lets
assume, that the number of tables per user is m, and we have n users.


wp-1-firsttable1, wp-1-table2,wp-1-tablem

wp-2-firsttable1, wp-2-table2,,wp-2-tablem

..

wp-n-firsttable1, wp-n-table2,,wp-n-tablem


I cant make cakephp work for that!, any input.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---