Welcome Guest, Not a member yet? Register   Sign In
  Form that Submits to a Database
Posted by: El Forum - 09-29-2008, 12:56 AM - Replies (19)

[eluser]Jason McCallister[/eluser]
I have been reading the user guide and I have been trying to figure something out. Basically I need a quick and simple tutorial that explains how to create a simple form that submits to a database. I know how to connect to the database, I'm just confused on how to create a form without the scaffolding.

Also any good resources from the community?


  PDO Extension
Posted by: El Forum - 09-29-2008, 12:40 AM - Replies (8)

[eluser]hykoh[/eluser]
Hi,

is there any PDO Database Extension for CI ? I just started to work with CI yesterday, but like to work with PDO and the "real" prepared statements for mySQL. CI has only Pseudo-prepared-statements mh ?


  PostgreSQL where
Posted by: El Forum - 09-28-2008, 11:24 PM - Replies (7)

[eluser]Kfrico[/eluser]

Code:
$sql = "SELECT * FROM "AssocPersonMaster" WHERE "PersonID" = '9788771' or "Status" = 'b'";
$query = $this->db->query($sql);

Parse error: syntax error, unexpected T_STRING in E:\Program Files\Apache Software Foundation\www\pg\system\application\models\modelinsert.php on line 50

why

在sql裡面不能加雙引號嗎?
但是不加雙引號postgresql確無法判別大小寫之分
這該怎麼辦阿?


  Codeigniter that suitable for PHP 6
Posted by: El Forum - 09-28-2008, 10:38 PM - Replies (7)

[eluser]chandrajatnika[/eluser]
I have some problem about my CI application when I install it on PHP 6.
this is some error:

Code:
Deprecated: Assigning the return value of new by reference is deprecated in J:\\Webmaster_File\\Project\\product_database\\system\\codeigniter\\Common.php on line 123

Deprecated: Assigning the return value of new by reference is deprecated in J:\\Webmaster_File\\Project\\product_database\\system\\codeigniter\\Common.php on line 129

Fatal error: Call to undefined function set_magic_quotes_runtime() in J:\\Webmaster_File\\Project\\product_database\\system\\codeigniter\\CodeIgniter.php on line 53

I remove \"Call Time Pass by Reference\" on Common.php by remove \"&\" on object declaration
Code:
$obj =& new Class(); // before
$obj = new Class(); // after

I remark \"set_magic_quotes_runtime()\" statement from CodeIgniter.php, and the last is i create my own \"get_magic_quotes_gpc()\" function by only returning a boolean false.

After that, my application do unfinish looping and my web server got some error.

Could you please help me how to handle this?


  Controller Sub-Folders?
Posted by: El Forum - 09-28-2008, 10:33 PM - Replies (5)

[eluser]Moon 111[/eluser]
My website has two languages so I was going to have an english sub-folder and a hebrew sub-folder inside my controller folder. Is this not allowed?

How should I do this instead?

Thanks,
- Moshe


  error in using ODBC
Posted by: El Forum - 09-28-2008, 08:35 PM - Replies (1)

[eluser]kyko[/eluser]
I am having trouble fetching the data using System DSN and ODBC. When i try issuing a query, it works but when fetching the rows, i got this error message

Code:
Fatal error: Call to a member function result() on a non-object in D:\webroot\sqws\cfapp\controllers\welcome.php on line 21

The script generating the error

Code:
$this->db->like('field', 'JOE');
        $query2 = $this->db->get('database.table');
        foreach ($query2->result() as $row)
        {
           echo $row->field."<br />";
        }

Here's my config

Code:
$db['default']['hostname'] = "System";
$db['default']['username'] = "scrpt";
$db['default']['password'] = "ex0du5";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "odbc";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

I might be forgetting something..?


  shopping cart and Paypal?
Posted by: El Forum - 09-28-2008, 07:28 PM - No Replies

[eluser]generalsalt[/eluser]
I have the task to build a e-commerce website that sells shirts. They want something where the customer can checkout without being directed to a gateway (Paypal etc..). They also want something to keep track of inventory.

I know there are monster frameworks like OS-Commerce and stuff like that..but this is actually I really small company (7 shirts for sale)..that seems a little overkill..maybe?

Does CI have any plugins / libraries that can deal with this sort of thing? Like, maybe a Paypal 'Direct Pay' plugin?

Please help!!!!! Smile


  building a list of categories
Posted by: El Forum - 09-28-2008, 05:43 PM - Replies (2)

[eluser]paulcj2[/eluser]
Building a list of categories, I am getting undefined variables in the views for my header and body of my category page.


My controller code includes:

Code:
$data = array(); //holds data for header, homepage & footer views
            $sql = "
            SELECT id, name, descrip_cat, keywords_cat, order_cat
            FROM category_products
            WHERE site_id = '" . SITE_ID . "'
            AND visible='Y'
            ORDER BY order_cat, name";
                
        $rs = $this->db->query($sql);
        foreach ($rs->result() as $row) {
            $prod_cat['id_cat'] = $row->id;
            $prod_cat['name_cat'] = $row->name;
            $prod_cat['descrip'] = $row->descrip_cat;
            $prod_cat['keywords'] = $row->keywords_cat;
            $prod_cat['order_cat'] = $row->order_cat;
            $prod_cat_results[] = $prod_cat;
            }
            $data['prod_cat_results'] = $prod_cat_results;
            $data['title'] = "Product categories";

        $this->load->view('page/header', $data);    
        $this->load->view('prod/cats_prod', $data);
        $this->load->view('page/footer');
My view code includes:
Code:
foreach ($prod_cat_results as $prod_cat) {
  echo "<h3><a href='/cat_prod/" . SITE_ADDRESS . "/$id_cat'>$name_cat</a></h3>";
  echo "<p>$descrip</p>";
  }

I suspect the problem is here
Code:
$prod_cat_results[] = $prod_cat;
            }
            $data['prod_cat_results'] = $prod_cat_results;
Any thoughts?


  Prefill forms from DB array
Posted by: El Forum - 09-28-2008, 04:10 PM - Replies (8)

[eluser]opel[/eluser]
Please could anyone tell me if it is possible or how to prefill a form view with data from my model and controller ?

What I have at the moment is :

Model :

Code:
function get($table, $id)
    {
        $query = $this->db->query("SELECT * FROM $table WHERE $id");
        $result =  $query->row();
    
        var_dump($result);
    
    }

Controller :

Code:
function edit($id){
        
        $data['pagetitle'] = 'Edit';
        
        //Select data based on ID
        $data['body'] = $this->Pages_model->Get('pages', $id);
        
        //write out data
        $this->template->write_view('content', 'pages/page_add', $data);
        
        //render
        $this->template->render();
        
    }

View :

Code:
<h1>&lt;?= $pagetitle; ?&gt;</h1>

&lt;?php

  $id = $this->uri->segment(3);

if($id == NULL){
  $id = 'X';
}




$form = array('name'=>'text','rows' => '10', 'cols' => '30');

$attributes = array('class' => 'email', 'id' => 'myform');

echo form_open('pages/form', $attributes); ?&gt;


&lt;?php echo $this->validation->error_string; ?&gt;

<table>
    <tr>
         <td><label><div align="right">Title : </div></label></td>
        <td>&lt;?= form_input('title'); ?&gt;</p></td>
    </tr>
    <tr>
             <td><label>Message : </label></td>
            <td colspan="2">&lt;?= form_textarea($form); ?&gt;</p></td>
    </tr>
    <tr>
             <td><label><div align="right">Order : </div></label></td>
            <td>&lt;?= form_input('order'); ?&gt;</p></td>
    </tr>
    <tr>
            <td>&nbsp;</td>
            <td>&lt;?= form_submit('submit', 'Add Page') ?&gt;</td>
    </tr>
    <tr>
            <td>&nbsp;</td>
            <td>&lt;?= form_hidden('id', $id) ?&gt;</td>
    </tr>
</table>
&lt;? echo form_close(); ?&gt;


  locking tables in database, is it needed?
Posted by: El Forum - 09-28-2008, 01:42 PM - Replies (4)

[eluser]Unknown[/eluser]
I'm sorry for my question, others more familiar with databases probably find it pretty trivial:

I have a many-to-many relationship (products, categories, productcategories) and when I update a specific product (flushing and adding new categories in the connector table as well) I think I really ought to do LOCK TABLES (which I indeed do, using LOCK TABLES with MySQL), but there's no such method in CI's ActiveRecord class - and transactions are not supported with MyIsam tables.

I have read most tutorials I could find in Google on locking tables and I still think I have to lock tables, though I might be wrong: what's the proper way to do it? I would like to be database agnostic in case I end up with a Postgres DB, which does have locking, but clearly states that it is not part of the SQL standard... any suggestions? Thanks!


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Version number stays un-u...
by trunky
2 hours ago
codeigniter4/queue Not lo...
by mywebmanavgat
6 hours ago
Array to HTML "Table"
by HarmW94
7 hours ago
shortcodes for ci4
by xsPurX
9 hours ago
TypeError when trying to ...
by b126
Today, 12:04 AM
Webhooks and WebSockets
by InsiteFX
Yesterday, 10:39 AM
Retaining search variable...
by pchriley
Yesterday, 05:46 AM
Reading a session variabl...
by xanabobana
Yesterday, 05:05 AM
Update to v4.5.1, same us...
by kenjis
04-17-2024, 07:47 PM
Codeigniter 4 extend core...
by Semsion
04-17-2024, 05:08 AM

Forum Statistics
» Members: 84,589
» Latest member: untung22me
» Forum threads: 77,560
» Forum posts: 375,900

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB