Chicken-run Manager
Posts: 9
54 credits Members referred : 0
Booting up...
« Reply #6 on: Jun 15, 2008, 12:26:01 PM »
In the next update can you write a table selector for the get_property ex.: function get_property($property, $table)?
Thx sorry for my english I like you class! Nice work!
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8269
42601 credits Members referred : 3
« Reply #7 on: Jun 15, 2008, 01:40:46 PM »
For the moment you can get properties from the user table. In order to do what you want the script must have more complexed setup in order to understand joins from other tables, but yet it is a good idea
Chicken-run Manager
Posts: 9
54 credits Members referred : 0
Booting up...
« Reply #8 on: Jun 15, 2008, 01:43:47 PM »
Hello Again!
I written this function from insertUser:
Code:
/** * Insert any data to any table * */ function insert_property($data, $table){ if (!is_array($data)) $this->error('Data is not an array', __LINE__); foreach ($data as $k => $v ) $data[$k] = "'".$this->escape($v)."'"; $this->query("INSERT INTO `$table` (`".implode('`, `', array_keys($data))."`) VALUES (".implode(", ", $data).")"); return (int)mysql_insert_id($this->dbConn); }
But it isn't insert What's the problem?
Thx and again sorry for my english
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8269
42601 credits Members referred : 3
« Reply #9 on: Jun 15, 2008, 01:46:00 PM »
The code looks ok. I suppose the data that you give to the function is wrong
Chicken-run Manager
Posts: 9
54 credits Members referred : 0
Booting up...
« Reply #14 on: Jun 15, 2008, 09:06:52 PM »
Yes, i send but i cant write update with arrays
Chicken-run Manager
Posts: 9
54 credits Members referred : 0
Booting up...
« Reply #15 on: Jun 15, 2008, 09:19:21 PM »
Code:
/** * Delete data from any table * Use arrays: *You can delete one thing in one array *$array = array( *'deletable' => 'WHERE' *); *$this->delete_property($data, $table); * */
function delete_property($data, $table){ if (!is_array($data)) $this->error('Data is not an array', __LINE__); foreach ($data as $k => $v ) $data[$k] = "'".$this->escape($v)."'"; $this->query("DELETE FROM `$table` `".implode('`, `', array_keys($data))."` WHERE ".implode(", ", $data).""); return (int)mysql_insert_id($this->dbConn); }
« Last Edit: Jun 15, 2008, 09:22:32 PM by DJ.Pety »
Chicken-run Manager
Posts: 9
54 credits Members referred : 0
Booting up...
« Reply #16 on: Jun 15, 2008, 09:21:01 PM »
ohh this function doesnt work sorry
Chicken-run Manager
Posts: 9
54 credits Members referred : 0
Booting up...
« Reply #17 on: Jun 15, 2008, 09:25:24 PM »
I'm not good at php I learn...
Chicken-run Manager
Posts: 9
58 credits Members referred : 0
« Reply #18 on: Jun 16, 2008, 02:43:28 PM »
NOT TESTED CODE!! I'm sure there's a better solution, but this one should work fine.
Edit: Updated Code on next Page
« Last Edit: Jun 18, 2008, 03:27:52 PM by Downlord »
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8269
42601 credits Members referred : 3
« Reply #19 on: Jun 16, 2008, 03:34:50 PM »
No don't use this code, it is not sql injection safe....