Other difference,

I am using the $dataSource->_execute() inside a Controller, I untherstand
You want to use it inside a Shell.

Is this correct?, Is there a difference in environment?

Regards.


El 14 de octubre de 2009 09:27, Yuncong Zhang <[email protected]> escribió:

> Thank you Jorge,
>
> The syntax is correct. Maybe there are no public properties in that class.
>
> I worked it out, using cakephp fetchResult() function.
>
> Yuncong
>
> 2009/10/14 Jorge Horacio Cué Cantú <[email protected]>
>
> Hello $dataSource->_execute($sql) calls the untherlying database driver.
>> for example for mysqli it calls mysqli_query().
>>
>> IMHO should check the mysqli documentation to check the return value.
>>
>> BTW, if there is any sintax error in the SQL statement, then the function
>> normally returns false, are You shure the SQL statement is complete when
>> sent to _execute method?.
>>
>> Regards.
>>
>> El 13 de octubre de 2009 14:02, blah <[email protected]> escribió:
>>
>>> Hello Jorge,
>>>
>>> I meet similar problem. When I try your method, the console shows
>>> empty mysqli_result Object for any results no matter what SQL I put in
>>> $sql_statement. Do you know why?
>>>
>>> mysqli_result Object
>>> (
>>> )
>>>
>>> Thank you in advance.
>>>
>>> Yc Zhang
>>>
>>> On Sep 24, 5:43 pm, Jorge Horacio Cué Cantú <[email protected]>
>>> wrote:
>>> > Hello,
>>> >
>>> > I had a similar problem. I have an Install controller that executes a
>>> SQL
>>> > script in ordert to create the database.
>>> > What I have done is somethjing similar to:
>>> >
>>> > uses('model'.DS.'connection_manager');
>>> > $db = ConnectionManager::getInstance();
>>> > $dataSource = $db->getDataSource('default');
>>> >
>>> > // The to execute each SQL statement do:
>>> >
>>> > $result = $dataSource->_execute($sql_statement');
>>> > if ($result) {
>>> > // success
>>> >
>>> > } else {
>>> > // failure
>>> > }
>>> >
>>> > I hope this helps you. Regards
>>> >
>>> > 2009/9/24 Stinkbug <[email protected]>
>>> >
>>> >
>>> >
>>> > > I'm somewhat familiar with the schema stuff.  However, the .sql file
>>> > > is a file that's going to be provided to us and not a file that will
>>> > > be generated by cake.  Our .sql file isn't just about the schema, it
>>> > > could be large amounts of data manipulation using sql.  So unless the
>>> > > schema stuff will execute a .sql file (rather than just generate it).
>>> > > I don't think it will work for us.  That's why I was trying to get
>>> the
>>> > > code above to work.
>>> >
>>> > > Any other thoughts?
>>> >
>>> > > On Sep 23, 4:39 pm, Sam Sherlock <[email protected]> wrote:
>>> > > > I think you want to create a schemahttp://
>>> > > book.cakephp.org/view/735/Generating-and-using-Schema-files
>>> > > > - S
>>> >
>>> > > > 2009/9/23 Stinkbug <[email protected]>
>>> >
>>> > > > > I'm trying to execute a bunch of sql from a .sql file from the
>>> > > > > console.  I was trying to use the query method inside the Model
>>> class,
>>> > > > > but I keep getting the following error.
>>> >
>>> > > > > Error: Missing database table 'models' for model 'Model'
>>> >
>>> > > > > Below is my code:
>>> >
>>> > > > > <?php
>>> > > > > App::import('Core', array('Model'));
>>> > > > > class UpgradeShell extends Shell {
>>> > > > >        var $uses = array();
>>> >
>>> > > > >        function main() {
>>> > > > >                $filename = APP . 'config/sql/upgrade.sql';
>>> > > > >                if (file_exists($filename)) {
>>> > > > >                        $handle = fopen($filename, "r");
>>> > > > >                        $sql = fread($handle,
>>> filesize($filename));
>>> > > > >                        fclose($handle);
>>> > > > >                        echo $sql;
>>> > > > >                        if ($sql) {
>>> > > > >                                //Model::query($sql);
>>> > > > >                                $model = new Model();
>>> > > > >                                //$model->query($sql);
>>> > > > >                        }
>>> > > > >                }
>>> > > > >        }
>>> >
>>> > > > > }
>>> > > > > ?>
>>> >
>>> > > > > When I try Model::query($sql);
>>> >
>>> > > > > I get the following error:
>>> > > > > Notice: Undefined property: UpgradeShell::$Model in C:\wamp\www\
>>> rx.com
>>> > > > > \app\vendors\shells\upgrade.php on line 13
>>> >
>>> > > > > Fatal error: Call to a member function query() on a non-object in
>>> C:
>>> > > > > \wamp\www\rx.com\app\vendors\shells\upgrade.php on line 13
>>> >
>>> > > > > I don't really need to specify models, I just want to execute the
>>> > > > > queries inside the .sql file.
>>>
>>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to